Chat with a LIVE Microsoft Access Expert!
 
       
 

         

   

Go Back   Access World Forums > Microsoft Access Discussion > General

 
 
Chat with a LIVE Microsoft Access Expert!
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-17-2003, 07:24 PM
Essendon Essendon is offline
Member
 
Join Date: Oct 2001
Location: Australia
Posts: 65
Essendon
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
Reply With Quote
Sponsored Links
  #2  
Old 05-17-2003, 08:21 PM
Benny Wong Benny Wong is offline
Registered User
 
Join Date: Jun 2002
Location: San Francisco, Ca.
Posts: 65
Benny Wong
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.
Reply With Quote
  #3  
Old 05-18-2003, 03:12 AM
Essendon Essendon is offline
Member
 
Join Date: Oct 2001
Location: Australia
Posts: 65
Essendon
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.
Reply With Quote
  #4  
Old 05-18-2003, 05:41 AM
Tim K. Tim K. is offline
Registered User
 
Join Date: Aug 2002
Location: Thailand
Posts: 242
Tim K.
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)
Reply With Quote
  #5  
Old 05-18-2003, 07:35 AM
Fornatian's Avatar
Fornatian Fornatian is offline
Dim Person
 
Join Date: Aug 2000
Location: England
Posts: 1,396
Fornatian is on a distinguished road
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.
Reply With Quote
  #6  
Old 05-18-2003, 07:35 AM
Essendon Essendon is offline
Member
 
Join Date: Oct 2001
Location: Australia
Posts: 65
Essendon
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.
Reply With Quote
  #7  
Old 05-18-2003, 07:39 AM
Fornatian's Avatar
Fornatian Fornatian is offline
Dim Person
 
Join Date: Aug 2000
Location: England
Posts: 1,396
Fornatian is on a distinguished road
http://www.geocities.com/Athens/Atri...sciitutor.html
__________________
Ian

build a better system and they'll build a better idiot.
Reply With Quote
Sponsored Links
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 09:49 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) copyright 2009 Access World