Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel macro

Status
Not open for further replies.

dunner44

MIS
Jul 27, 2004
32
US
I have a command button in Excel. When I click on the button, I want it to do the same command as if I were to click on >File >Open. And I want it to automatically go to a specific folder, C:\My Documents\Projects.

Does anyone have the code for this?

TIA
 
Do you want it to automatically open a particular file, or just bring up the dialogue box that will allow you to select a file in that folder?

[tt]-John[/tt]
________________________
To get the best answers fast, please read faq181-2886
 
I want it to open up the dialogue box so I can select the file
 
dunner44 - please note that unlike a lot of sites, this is NOT a helpdesk.

You are expected to try it yourself and post if you get stuck on a specific problem.

Do NOT expect someone to just write code for you unless you are willing to pay them your salary for doing your work.

Rgds, Geoff

"Three things are certain: Death, taxes and lost data. Guess which has occurred"

Please read FAQ222-2244 before you ask a question
 
xlbo, sorry for the confusion. Here is the code I tried...

Sub Button1_Click()
Workbooks.Open "C:\My Documents\Projects\"
End Sub

Here is where I get stuck. Does anyone have any solutions?

Thank you.
 
You need this:
Code:
dlgAnswer = Application.Dialogs(xlDialogOpen).Show("C:\My Documents\Projects\")

help keyword is "Dialog"

ps - this should really be asked in the VBA forum (Forum707)

Rgds, Geoff

"Three things are certain: Death, taxes and lost data. Guess which has occurred"

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top