ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Common Dialog Boxes (https://www.excelbanter.com/excel-programming/272547-common-dialog-boxes.html)

Lionel Fridjhon

Common Dialog Boxes
 
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

patrick molloy

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
.



All times are GMT +1. The time now is 06:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com