How to use macro to open an specific file

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

Guest

To anyone that can help me:

I need to create a macro that allows the user to select a specific file, no
matter what the name of the file is. Also, the file may be located anywhere.
In short, I want to enable the user to select the file in any directory
location, but, when it opens, has the restriction of the content validation.

Can someone give me a light?
Thank you!!
 
Hello Rafael,

To prompt the user for the file to open, use something
like:

Sub Macro1()

Dim myfile As String

myfile = Application.GetOpenFilename()
Workbooks.Open FileName:=myfile
End Sub

Look at the help in VBA for all of the valid options for
GetOpenFilename().

Not sure what you mean by "has the restriction of the
content validation" though.

Hope this helps,

Kris
 

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