Open File (picture) with VBA

  • Thread starter Thread starter Jane
  • Start date Start date
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
 
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 :-)
 
Back
Top