Find File

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

Guest

Can I create a macro that would go to the C: Drive and allow me to pick a
file and open it. I want to be able to choose the file after I hit the macro
button.
 
Gary

The code below, throws the standard Open File dialog, allows you to find the
file, clicking OK captures the name in the variable fName, but does not open
it. The next line does that, using the name in the variable to identify the
file to open

Sub OpenFile()
Dim fName As String
fName = Application.GetOpenFilename()
Workbooks.Open Filename:=fName
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 

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