Open workbook selected form dialog

H

Hennie Neuhoff

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
 
T

Trevose F

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

Replace MsgBox statement with Workbooks.Open (fNameAndPath)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top