Open File (picture) with VBA

J

Jane

Hello everyone

I wonder if someone could help with this problem.

I have a continuous form with some numbers 1 2 3 4 etc on each record
These are the same as some picture file name

eg
"C:\My Documents\My Pictures\1.jpg"
"C:\My Documents\My Pictures\2.jpg"
"C:\My Documents\My Pictures\3.jpg"


I have selected Open With so that pictures with .jpeg will open with
picture manager

Is there a code that I can put on a button that will open the picture with
picture manager

I have looked at a ShellCall but it seems not to be needed as the default
program for .jpeg is already MS Picture Manager

Thank you for your assistance

Jane Hollin
 
W

Wayne-I-M

Add this to your button OnClick

Private Sub ButtonName_Click()
Dim strPath As String
strPath = Me.TextBoxName & ".jpg"
If Dir(strPath) <> "" Then
Application.FollowHyperlink strPath
Else
MsgBox "Picture "& strPath & Chr(13) & Chr(13) & "You can't edit this photo
as it does not exist ", vbInformation, "Picture not found"
End If
End Sub


I like this - I may use it in one of the new applicaitons I am creating :)
 

Ask a Question

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. After that, you can post your question and our members will help you out.

Ask a Question

Top