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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pick file from "Open File" always from same folder 1

Status
Not open for further replies.

xsubzeroz

Technical User
Oct 15, 2002
39
CA
Can someone please help me. Thanks in advance. In Excel I'm using click button to have "Open File" window come up. I would like to do, when I click button I want "Open File" window come up always defaulting to same folder and I then I will select file I need. Right now I have very, very simple code:

Sub Macro2()
Excel.Application.GetOpenFilename
End Sub

Can someone tell me what to add to default to same folder all the time. Lets say "C:\My Documents\Parts". I would really appreciate your help.
 
Thank you SkipVought, that's a very handy option to know. The only thing that I want to know if I do the way you said, and save this file on network with these command buttons, if other people open this file, will they will be redirect to same folder?? Or is it just my computer will be set to that?? Thanks.
 
Get the user default, set yours, get the filename, set it back to user default
Code:
With Application 
  UserDefault = .DefaultFilePath 
  .DefaultFilePath = "C:\My Documents\vbaProjects"
  fName = .GetOpenFilename
  .DefaultFilePath = UserDefault 
End with
:)

Skip,
 
Hi
You could also use
ChDir ""C:\My Documents\Parts"
before getopenfilename

This changes the default for the current xl session. Combine it with Skip's code to remember the default and reset it and you're away!
;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top