ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open workbook selected form dialog (https://www.excelbanter.com/excel-programming/422363-open-workbook-selected-form-dialog.html)

Hennie Neuhoff

Open workbook selected form dialog
 
Hi All,
Below is my code to get the workbook selected by the user. For some or other
reason this dummy
can't get the code to open the selected file. I would like to substitute the
msgbox with the code to
open the file. Any advice would be appreciated.
Thanks in advance



Sub GetFileExample()
Dim fNameAndPath As Variant
fNameAndPath = Application.GetOpenFilename _
(FileFilter:="Excel Files (*.XLS), *.XLS", _
Title:="Select File To Be Opened")
If fNameAndPath = False Then _
Exit Sub
MsgBox fNameAndPath

End Sub

--
HJN

Trevose F

Open workbook selected form dialog
 
On Jan 13, 12:13*pm, Hennie Neuhoff
wrote:
Hi All,
Below is my code to get the workbook selected by the user. For some or other
reason this dummy * * *
can't get the code to open the selected file. I would like to substitute the
msgbox with the code to
open the file. Any advice would be appreciated.
Thanks in advance * * *

Sub GetFileExample() * *
Dim fNameAndPath As Variant * *
fNameAndPath = Application.GetOpenFilename _ * *
(FileFilter:="Excel Files (*.XLS), *.XLS", _ *
Title:="Select File To Be Opened")
If fNameAndPath = False Then _
Exit Sub
MsgBox fNameAndPath

End Sub

--
HJN


Replace MsgBox statement with Workbooks.Open (fNameAndPath)


All times are GMT +1. The time now is 12:11 PM.

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