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

Discussion in 'Microsoft Access VBA Modules' started by Daniel Pineault, Jun 20, 2009.

  1. 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
    >
    >
     
    Daniel Pineault, Jun 20, 2009
    #1
    1. Advertisements

  2. Daniel Pineault

    Willis Guest

    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
    > >
    > >
     
    Willis, Jul 4, 2009
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Sudhendra

    xp shell command using vba

    Sudhendra, Feb 4, 2004, in forum: Microsoft Access VBA Modules
    Replies:
    0
    Views:
    320
    Sudhendra
    Feb 4, 2004
  2. Katrina

    Shell code to open MDB file

    Katrina, Apr 21, 2004, in forum: Microsoft Access VBA Modules
    Replies:
    1
    Views:
    657
    Albert D. Kallal
    Apr 21, 2004
  3. Rod

    Height & width in pixels of a gif or jpg file from VBA

    Rod, Oct 4, 2004, in forum: Microsoft Access VBA Modules
    Replies:
    2
    Views:
    787
  4. Guest

    Compacting via VBA (Shell stays open)

    Guest, Apr 1, 2005, in forum: Microsoft Access VBA Modules
    Replies:
    10
    Views:
    1,948
    Dirk Goldgar
    Apr 5, 2005
  5. AviA

    Open protected Mdb file from another file using VBA

    AviA, Dec 26, 2005, in forum: Microsoft Access VBA Modules
    Replies:
    3
    Views:
    1,850
    AviA via AccessMonster.com
    Dec 29, 2005
  6. Guest
    Replies:
    1
    Views:
    703
    John Nurick
    Aug 24, 2006
  7. Guest

    Open and save a bmp file in Microsoft Paint

    Guest, May 22, 2007, in forum: Microsoft Access VBA Modules
    Replies:
    7
    Views:
    2,335
    Stephen Lebans
    May 26, 2007
  8. beavetoots

    VBA Shell and Saving

    beavetoots, Jul 10, 2008, in forum: Microsoft Access VBA Modules
    Replies:
    0
    Views:
    250
    beavetoots
    Jul 10, 2008
Loading...