Common Dialog Boxes

  • Thread starter Thread starter Lionel Fridjhon
  • Start date Start date
L

Lionel Fridjhon

I have a common dialog box "File Open" that appears when
I initialize a user form.

I select the file I need, but when I press OK, the file
does not open, although my selected filename appears in
the common dialog box as a filename property.

What steps must I take to open the file on the screen?

Lionel
 
the comm dialog box has a .filename property which will
hold the name of the selected file or will be empty (
null string) if cancelled.

add a CDB and a button to a userform and add this code

Private Sub CommandButton1_Click()
Dim FN As String
If FN <> "" Then
Workbooks.Open FN
End If
End Sub


Private Function GetFileName() As String
With CommonDialog1
.CancelError = False
.ShowOpen
GetFileName = .Filename
End With
End Function


HTH
Patrick Molloy
Microsoft Excel MVP
 
Back
Top