Hi all

I have a userform where the user clicks a command button to select a gif/jpeg using the getopenfile function, the file path a is then loaded in to a text box and loaded in an image. I noticed that when the user cancelled before selecting a file it caused a crash. I have added some code to prevent this but now it crashed when an image is selected.

I am very new to this and know tha its probable a gleaming error in the code below.

Private Sub CommandButton2_Click()

Dim Fname As String
Fname = Application.GetOpenFilename(FileFilter:="Pictures,*.jpg; *.gif")
If Fname = False Then
  MsgBox "No file selected. Cannot continue."
    Exit Sub
Else
Me.Path.Value = Fname
Image1.Picture = LoadPicture(Path)
  End If
End Sub
Thanks in advance