PC Review


Reply
Thread Tools Rate Thread

RE: VBA - using Shell to open a .jpg file in MS Paint

 
 
Daniel Pineault
Guest
Posts: n/a
 
      20th Jun 2009
Here try this:

Function OpenImage(sFileFullPathAndName)
On Error GoTo Error_Handler

Shell Chr(34) & "C:\Windows\System32\mspaint.exe" & Chr(34) & " " & _
Chr(34) & sFileFullPathAndName & Chr(34), 1

If Err.Number = 0 Then Exit Function

Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
Err.Number & vbCrLf & "Error Source: OpenImage" & vbCrLf & "Error
Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Exit Function
End Function

You simply call it like so:
OpenImage("D:\Main\My Documents\My Pictures\Portrait.jpg")
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"Willis" wrote:

> I have been successful in opening a PDF file with Adobe by using the Shell
> function, but cannot seem to be able to open a JPG file with MS Paint.
>
> fullpath = xPath & Me.Path
> Dim RetVal
> RetVal = Shell("C:\Windows\System32\mspaint.exe " & fullpath,
> vbMaximizedFocus)
>
>
> Paint error "C:\Users\Willis.bmp was not found" is returned from MS Paint. I
> am not using a BMP format and don't know where the .bmp comes from
>
> Your help would be greatly appreciated.
>
> Willis
>
>

 
Reply With Quote
 
 
 
 
Willis
Guest
Posts: n/a
 
      4th Jul 2009

IT WORKS!!! Thank you, Thank you, Thank you...Willis

"Daniel Pineault" wrote:

> Here try this:
>
> Function OpenImage(sFileFullPathAndName)
> On Error GoTo Error_Handler
>
> Shell Chr(34) & "C:\Windows\System32\mspaint.exe" & Chr(34) & " " & _
> Chr(34) & sFileFullPathAndName & Chr(34), 1
>
> If Err.Number = 0 Then Exit Function
>
> Error_Handler:
> MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
> "Error Number: " & _
> Err.Number & vbCrLf & "Error Source: OpenImage" & vbCrLf & "Error
> Description: " & _
> Err.Description, vbCritical, "An Error has Occured!"
> Exit Function
> End Function
>
> You simply call it like so:
> OpenImage("D:\Main\My Documents\My Pictures\Portrait.jpg")
> --
> Hope this helps,
>
> Daniel Pineault
> http://www.cardaconsultants.com/
> For Access Tips and Examples: http://www.devhut.net
> Please rate this post using the vote buttons if it was helpful.
>
>
>
> "Willis" wrote:
>
> > I have been successful in opening a PDF file with Adobe by using the Shell
> > function, but cannot seem to be able to open a JPG file with MS Paint.
> >
> > fullpath = xPath & Me.Path
> > Dim RetVal
> > RetVal = Shell("C:\Windows\System32\mspaint.exe " & fullpath,
> > vbMaximizedFocus)
> >
> >
> > Paint error "C:\Users\Willis.bmp was not found" is returned from MS Paint. I
> > am not using a BMP format and don't know where the .bmp comes from
> >
> > Your help would be greatly appreciated.
> >
> > Willis
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't close paint or open new paint =?Utf-8?B?RGFjZg==?= Windows XP Basics 0 12th Feb 2007 11:25 PM
RE: Controls are slow to paint / Controls Paint Slowly =?Utf-8?B?SnJzbWl0aA==?= Microsoft Dot NET Framework Forms 3 10th Jan 2006 07:07 AM
Deep Paint 2 (NB not Deep Paint 3D) released as freeware Steerpike Freeware 5 4th Jun 2005 04:38 AM
Tux Paint - Open Source Children Paint Program CoMa Freeware 2 15th Mar 2005 04:12 PM
Microsoft Paint Wont Paint Colors =?Utf-8?B?cGFpbnRoZWxwcGxlYXNl?= Windows XP Help 2 13th Jul 2004 01:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:15 PM.