Macro To Open a User selected File

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a macro that allows the user to select the file. I have figured out to
write a macro for specific path however, as this workbook will go to many
differnt users that will have differnt names and paths for the file. Any help
would be awsome. Thank in advance.

-CM
 
One way

There is no code to test if the workbook is open in this example

Sub test()
Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = ThisWorkbook.Path
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
If FName <> False Then
Workbooks.Open (FName)
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub
 
Your A PRO!

Ron de Bruin said:
One way

There is no code to test if the workbook is open in this example

Sub test()
Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = ThisWorkbook.Path
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
If FName <> False Then
Workbooks.Open (FName)
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub
 

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

Back
Top