Results 1 to 12 of 12
  1. #1
    NISMOJim is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    273

    Command button to open pictures with MS Picture Manager

    Hello to whoever can help me out,
    I have a command button on my form to open pictures from a file, which works great when using the MS Picture Manager program. Some of the computers here use other programs as their default for opening pictures which don't work as well as MSPM. Is there something I can write in my code that makes the pictures open with this program rather than whatever the users desktop is set for? I've gotten far with everyone's help on the forum, but am still a beginner with writing code.
    Thanks for any assistance!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I assume you're currently using FollowHyperlink. You can try Shell which lets you specify the program.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    NISMOJim is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    273
    That is correct. Here is a shortened version of what I am using to get to the pictures;

    Application.FollowHyperlink "T:\Operations\Folders\" & Me.[NRptNo] & "\01.JPG"

    Now I just need to force it to open with MS Picture Manager. I've never heard of the "Shell" that you mentioned, and have no idea how to use it. Please explain when you can get back to me.
    Thanks

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm about to leave, but check it out in VBA help and let me know if you get stuck.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    NISMOJim is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    273
    I've played with it some, but it still isn't cooperating. I changed the default picture program on my computer to something else to try it out. Now when I click the command button, MS Picture Manager opens showing thumbnails of the last pictures that were looked at, and then the "01.JPG" that I want to see opens over the top of it in my default program. Here is the code;

    Private Sub ComPic_Click()
    On Error GoTo ProcError
    Call Shell("C:\Program Files\Microsoft Office\OFFICE11\OIS.EXE", vbHide)
    Application.FollowHyperlink "T:\Operations\Folders\" & Me.[NRptNo] & "\01.JPG"
    ExitProc:
    Exit Sub
    ProcError:
    Select Case Err.Number
    Case 490
    MsgBox "No Pictures Available"
    Case Else
    MsgBox Err.Number & ": " & Err.Description, vbCritical, _
    "Error in cmdOK_Click Event Procedure..."
    End Select
    Resume ExitProc
    End Sub

    Anyone have any ideas of where I should go from here?
    Thanks again.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No, you use Shell instead of FollowHyperlink, not in addition to. You have the path to the executable first, then the path to the file to be run. Try

    Call Shell("C:\Program Files\Microsoft Office\OFFICE11\OIS.EXE T:\Operations\Folders\" & Me.[NRptNo] & "\01.JPG")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    NISMOJim is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    273
    I just plugged it in like you have it (all on the same line)

    Call Shell("C:\Program Files\Microsoft Office\OFFICE11\OIS.EXE T:\Operations\Folders\" & Me.[NRptNo] & "\01.JPG")

    and I get no response at all from the command button. I tried changing my default back to MSPM & still get no response. Do you know of anything else I can try? I appreciate your patience, as I know I wouldn't be able to figure this out on my own.
    Thanks for not losing interest.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I tested this and it worked as expected:

    Call Shell("C:\Program Files\Microsoft Office\OFFICE11\OIS.EXE X:\FolderName\images\EscaladeInterior.jpg", vbMaximizedFocus)

    Will your image path contain spaces or symbols?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    NISMOJim is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    273
    There are spaces and commas in the T: drive path. I also added the vbMaximizedFocus part at the end, still no results.
    It seems strange that the "Call Shell" part with just the path to MSPM worked fine, and the original path I had just to the T: drive folder worked ok, but together I get no response. Here is the exact code with nothing deleted to save space;

    Private Sub ComPic_Click()
    On Error GoTo ProcError
    Call Shell("C:\Program Files\Microsoft Office\OFFICE11\OIS.EXE T:\PG Operations\Accident, Incident, Injury Reporting\Accident Folders\" & Me.[NRptNo] & "\01.JPG", vbMaximizedFocus)
    ExitProc:
    Exit Sub
    ProcError:
    Select Case Err.Number
    Case 490
    MsgBox "No Pictures Available"
    Case Else
    MsgBox Err.Number & ": " & Err.Description, vbCritical, _
    "Error in cmdOK_Click Event Procedure..."
    End Select
    Resume ExitProc
    End Sub

    Do you see anything wrong with how this is written that I left out before?

    Thanks again.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No, it's the spaces and symbols. Try this:

    Call Shell("C:\Program Files\Microsoft Office\OFFICE11\OIS.EXE " & Chr(34) & "T:\PG Operations\Accident, Incident, Injury Reporting\Accident Folders\" & Me.[NRptNo] & "\01.JPG" & Chr(34), vbMaximizedFocus)

    If my copy/paste and substituting your path didn't go horribly wrong, that should work.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    NISMOJim is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    273
    Fantastic! That did the trick. Sorry I put you through so much for something you would have seen right away if I hadn't tried to shorten the post, & thanks so much for sticking with me. I've been looking for a good forum since the MS Access Forum went away, and I think I found it.
    Thanks again!

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Ah good, glad we got it sorted out. Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Use a command button to open a form
    By johnpaul in forum Forms
    Replies: 24
    Last Post: 09-23-2010, 12:29 PM
  2. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  3. Replies: 1
    Last Post: 07-07-2010, 11:06 AM
  4. Command Button
    By nashr1928 in forum Forms
    Replies: 2
    Last Post: 07-05-2010, 08:02 PM
  5. Open a linked subform with a command button
    By flablueeyedblond in forum Forms
    Replies: 0
    Last Post: 11-18-2005, 01:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums