Restrict Windows File Dialog to Initial Folder? 
Author Message
 Restrict Windows File Dialog to Initial Folder?

Now it's my turn to ask a question.  I know how to call the Windows
API File Open/Save dialog, but I'd like to be able to call it while
restricting the user to a single specified folder -- no changing
folders, no creating a new folder.  At the moment I can't see any way
to do this without hooking the window proc and doing extensive
customization.  Is there a simpler way that I'm overlooking, or
failing that, does any helpful soul out there already have VBA code
for this that they'd like to share?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



Wed, 10 Aug 2005 06:47:03 GMT  
 Restrict Windows File Dialog to Initial Folder?
Include OFN_NOCHANGEDIR as one of the flags.

Assuming you're using Ken's code, you could change the line

     If IsMissing(Flags) Then Flags = 0&

to

     If IsMissing(Flags) Then Flags = OFN_NOCHANGEDIR

Check out http://www.mvps.org/vbnet/code/comdlg/filedlgsoverview.htm (and
the related pages) at Randy Birch's VBNet.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele


Quote:
> Now it's my turn to ask a question.  I know how to call the Windows
> API File Open/Save dialog, but I'd like to be able to call it while
> restricting the user to a single specified folder -- no changing
> folders, no creating a new folder.  At the moment I can't see any way
> to do this without hooking the window proc and doing extensive
> customization.  Is there a simpler way that I'm overlooking, or
> failing that, does any helpful soul out there already have VBA code
> for this that they'd like to share?

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



Wed, 10 Aug 2005 07:22:00 GMT  
 Restrict Windows File Dialog to Initial Folder?
IN addition to Doug's response, here is code showing you how to set the
initial directory.
http://www.lebans.com/callbackbrowser.htm

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Quote:
> Now it's my turn to ask a question.  I know how to call the Windows
> API File Open/Save dialog, but I'd like to be able to call it while
> restricting the user to a single specified folder -- no changing
> folders, no creating a new folder.  At the moment I can't see any way
> to do this without hooking the window proc and doing extensive
> customization.  Is there a simpler way that I'm overlooking, or
> failing that, does any helpful soul out there already have VBA code
> for this that they'd like to share?

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



Wed, 10 Aug 2005 10:09:35 GMT  
 Restrict Windows File Dialog to Initial Folder?


Quote:
> Include OFN_NOCHANGEDIR as one of the flags.

> Assuming you're using Ken's code, you could change the line

>      If IsMissing(Flags) Then Flags = 0&

> to

>      If IsMissing(Flags) Then Flags = OFN_NOCHANGEDIR

No, that doesn't do what I want.  The user can still navigate to other
folders and choose files from there;  the OFN_NOCHANGEDIR flag just
keeps the chosen folder from becoming the new current directory.

Quote:
> Check out http://www.mvps.org/vbnet/code/comdlg/filedlgsoverview.htm
(and
> the related pages) at Randy Birch's VBNet.

Been there, done that, though of course I may have missed something.
Thanks anyway, Doug.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Quote:



> > Now it's my turn to ask a question.  I know how to call the
Windows
> > API File Open/Save dialog, but I'd like to be able to call it
while
> > restricting the user to a single specified folder -- no changing
> > folders, no creating a new folder.  At the moment I can't see any
way
> > to do this without hooking the window proc and doing extensive
> > customization.  Is there a simpler way that I'm overlooking, or
> > failing that, does any helpful soul out there already have VBA
code
> > for this that they'd like to share?

> > --
> > Dirk Goldgar, MS Access MVP
> > www.datagnostics.com

> > (please reply to the newsgroup)



Wed, 10 Aug 2005 15:42:06 GMT  
 Restrict Windows File Dialog to Initial Folder?
Thanks, Stephen, I'll have a look.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Quote:
> IN addition to Doug's response, here is code showing you how to set
the
> initial directory.
> http://www.lebans.com/callbackbrowser.htm

> --

> HTH
> Stephen Lebans
> http://www.lebans.com
> Access Code, Tips and Tricks
> Please respond only to the newsgroups so everyone can benefit.



> > Now it's my turn to ask a question.  I know how to call the
Windows
> > API File Open/Save dialog, but I'd like to be able to call it
while
> > restricting the user to a single specified folder -- no changing
> > folders, no creating a new folder.  At the moment I can't see any
way
> > to do this without hooking the window proc and doing extensive
> > customization.  Is there a simpler way that I'm overlooking, or
> > failing that, does any helpful soul out there already have VBA
code
> > for this that they'd like to share?

> > --
> > Dirk Goldgar, MS Access MVP
> > www.datagnostics.com

> > (please reply to the newsgroup)



Wed, 10 Aug 2005 16:01:14 GMT  
 Restrict Windows File Dialog to Initial Folder?

Quote:


> No, that doesn't do what I want.  The user can still navigate to other
> folders and choose files from there;  the OFN_NOCHANGEDIR flag just
> keeps the chosen folder from becoming the new current directory.

Ooops. Sorry, Dirk: I did the unthinkable and didn't test prior to posting.
Since I never rely on CurDir in my code, I didn't even think that that was
what OFN_NOCHANGEDIR meant.

And, to make things worse, the code snippet wouldn't have worked anyhow, as
it needed to be

      If IsMissing(Flags) Then Flags = ahtOFN_NOCHANGEDIR

Hopefully Stephen's answer is what you needed.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele



Wed, 10 Aug 2005 23:20:19 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Specify an initial folder for the Browse for folder dialog

2. W2000 - change initial focus of the file insert dialog box

3. HELP: VB4 initial file for an *.exe in windows 3.1x

4. Specify initial folder when using SHBrowseForFolder?

5. Save Dialog initial path

6. Changing the initial dialog box...

7. Setting initial position of SHGetPathFromIDList dialog

8. Folder Open Dialog - How to pre-select folder

9. Using Common Dialog control, possible to select folders and their associated files

10. Find Files and Folders dialog box...

11. File Dialog - Ghost Folder

12. File Dialog that allows selection of folders

 

 
Powered by phpBB® Forum Software