| Chat with a LIVE Microsoft
Access Expert! |
||||
|
||||
|
#1
|
|||
|
|||
|
Problem launching Paintbrush from code using SHELL
I have a database with images stored externally (with only the paths stored in the database). I want to create a button that would open a picture with the user's default picture viewer (eg. Ms Photo Editor, Ms Paint, Photoshop etc.).
Is there anyway that I can simulate the double click of a jpg file in windows from within my program (so that it would open it with the default viewer). If not, I would just like to make it open with mspaint. I have tried fiddling around with the shell command to get it to open with paintbrush: Call Shell(("C:\WINDOWS\System32\mspaint.exe C:\database\images\a picture.jpg"), vbMaximizedFocus) for some reason, as soon as you have a space in the path (like "a picture", or "C:\documents and settings" etc) Paintbrush returns an error becuase it doesn't like the space. If I change the code to open photoshop instead it works fine with the space. The trouble is that I have to get it working with paintbrush if nothing else. Any ideas? Thanks very much, Peter |
| Sponsored Links |
|
#2
|
|||
|
|||
|
MSPAINT.EXE
Hi Essendon
Try this code on the on-click event of the button. Private Sub Command0_Click() On Error GoTo Err_Command0_Click Call Shell("C:\Program Files\Accessories\MSPAINT.EXE", 1) Exit_Command0_Click: Exit Sub Err_Command0_Click: MsgBox Err.Description Resume Exit_Command0_Click End Sub Hope this helps you. |
|
#3
|
|||
|
|||
|
I am using windows xp. I don't have a c:\program files\accessories\ directory. I have no problems opening paint. I just cannot open any file that has a space in its path.
|
|
#4
|
|||
|
|||
|
Try this out.
Dim strAppName As String strAppName = "C:\WINDOWS\System32\mspaint.exe " & Chr(34) & "C:\database\images\a picture.jpg" & Chr(34) Call Shell(strAppName, vbMaximizedFocus) |
|
#5
|
||||
|
||||
|
You could also use :
Application.FollowHyperlink "MyFilePath" This should start up the default picture browser. Note that it may not always be editable because you can choose IE as the default viewer.
__________________
Ian build a better system and they'll build a better idiot. |
|
#6
|
|||
|
|||
|
Thanks very much
Works perfectly - thanks very much.
Whats the easiest way of finding out what char(34) is and what all the other char(x)'s are? I assume that char(34) is ". Thanks again. |
|
#7
|
||||
|
||||
|
__________________
Ian build a better system and they'll build a better idiot. |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|