View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
patrick molloy patrick molloy is offline
external usenet poster
 
Posts: 391
Default Common Dialog Boxes

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

-----Original Message-----
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
.