Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


BrowseForFolder dialog

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,44742
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> BrowseForFolder dialog
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 BrowseForFolder dialog - 3/22/2007 1:59:33 AM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
I'm using code along the following lines to allow my users to select a folder.  What I want to do is have the dialog open at a particular folder by default.  Any ideas?

Also I understand changing the constant OPTIONS to something other than 0 will give different results for the dialog.  Does anyone have a list of what available Options there are?

Cheers

Const WINDOW_HANDLE = 0
Const OPTIONS = 0

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
   (WINDOW_HANDLE, "Select a folder:", OPTIONS, "C:\")

If objFolder Is Nothing Then
   Wscript.Quit
End If

Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path

Wscript.Echo objPath
 
 
Post #: 1
 
 RE: BrowseForFolder dialog - 3/22/2007 2:07:03 AM   
  dm_4ever


Posts: 2726
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
To open to a specific folder then just change this "C:\" to the path of that folder.

Here is a link where they show some of the other options you can specify: http://www.visualbasicscript.com/m_2190/mpage_1/key_browseforfolder/tm.htm#17488

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to markmcrobie)
 
 
Post #: 2
 
 RE: BrowseForFolder dialog - 3/22/2007 2:23:34 AM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Sorry, I wasn't very clear:

As I understand it your suggestion would them limit the possible available to folders to the one I specify, and it's subfolders, but would prohibit navigating to anything further up the tree.  E.g. by setting it to:

C:\Test\Example

The user wouldn't be able to choose C: or C:\Test.

What I'm trying to do is still allow them to choose any folder from C:\ downwards, but have the dialog be at a specific folder already when it opens.

To make it clearer, it might help if I tell you that the whole point of this is because 90% of the time it'll be myself using the script, and 90% of the time I'll be using C:\Documents and Settings\mark.mcrobie\Desktop\For Renaming.  Therefore I want THAT folder to be the default when the dialog opens, for no other reason than it'll save me navigating to it every time I run the script.

However I still want to be able to choose other folders if need be.

Thanks

< Message edited by markmcrobie -- 3/22/2007 2:29:06 AM >

(in reply to markmcrobie)
 
 
Post #: 3
 
 RE: BrowseForFolder dialog - 3/22/2007 2:26:27 AM   
  dm_4ever


Posts: 2726
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
What OS are you looking at running this script on? If WinXP, then you may want to look at UserAccount.CommonDialog which allows you to specify a starting directory and still move around to some other location if you want.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to markmcrobie)
 
 
Post #: 4
 
 RE: BrowseForFolder dialog - 3/22/2007 2:42:44 AM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Yes, we all use XP Pro.

Do you have examples of how to use what you mentioned?

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: BrowseForFolder dialog - 3/22/2007 2:46:55 AM   
  dm_4ever


Posts: 2726
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
An example is shown here: http://www.visualbasicscript.com/m_44594/mpage_1/key_UserAccount.CommonDialog/tm.htm#44595

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to markmcrobie)
 
 
Post #: 6
 
 RE: BrowseForFolder dialog - 3/22/2007 9:55:01 AM   
  blaztoff

 

Posts: 6
Score: 0
Joined: 3/20/2007
Status: offline
This will open up a dialog big which will allow you tosearch the entire directory. Modify it to open it at the specific folder.


      

(in reply to dm_4ever)
 
 
Post #: 7
 
 RE: BrowseForFolder dialog - 3/22/2007 8:48:39 PM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Thanks, but that code does nothing unless I comment out:

Function BrowseForFolderDialogBox(strTitle)

and

End Function.

If I do THAT, the Browse For Folder dialog comes up.

I also notice you have strTitle in there? What is it for? It doesn't seem to be Dim'd at the start of the script

(in reply to blaztoff)
 
 
Post #: 8
 
 RE: BrowseForFolder dialog - 3/22/2007 8:57:56 PM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Ok, think I got it - I'm new to Functions, etc - if I guess right I have to actually call the function from my script somewhere?

If I add:

BrowseFolderDiaglogBox(strTitle)

To the bottom of your code, then run it, it works fine.

One question - where would I specify which folder to open it at?

(in reply to markmcrobie)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> BrowseForFolder dialog Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts