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

Browse for folder 1

Status
Not open for further replies.

ITSTOAST

Technical User
Mar 3, 2005
71
0
0
GB
Hi all the browse for folder function;
PHV has a code I found,

Set Sh = CreateObject("Shell.Application")
Set F = Sh.BrowseForFolder(0, "Choose a folder", 0, 17)
If (Not F Is Nothing) Then
'Add code here.
End If

this will put up a box and allow you to browse, how do I get the code to create a value that I can use in my script for the user to choose a folder?

Only the good die young, me I'm here forever :)
 
Still looking for an answer to this,
I would like to browse and have the result available to put into my script.

Only the good die young, me I'm here forever :)
 
A starting point:
Set Sh = CreateObject("Shell.Application")
Set F = Sh.BrowseForFolder(0, "Choose a folder", 0, 17)
If (Not F Is Nothing) Then
MsgBox f.Items.Item.Path
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Trying to add it to script now thanks

Only the good die young, me I'm here forever :)
 
mmmmm having a wee problem in intergarting script, the snippet of yours will perform the browse and display to dialouge box, but how do i get this path to add it to my script?

Only the good die young, me I'm here forever :)
 
The path you're looking for is F.Items.Item.Path

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Ah ha!

Only the good die young, me I'm here forever :)
 
nope no luck I Have this Code to which I wish to add a Browse Function,


'ITSTOASTS copy folder script with thanks to PHV & ANTYKREIST



Dim fso
Dim path
Dim oFolder
Dim oSubFolder
Const OverwriteExisting = True

transfer =Inputbox ("Enter folder containing files to transfer (TYPE or PASTE)")

Path =Inputbox("Enter Target Folder (TYPE or PASTE)")

Set fso = createobject("Scripting.FileSystemObject")
Folder = transfer & "\*"

Set oFolder = fso.GetFolder(Path)
Set colSubfolders = oFolder.Subfolders

For Each oSubfolder in colSubfolders
fso.CopyFolder Folder, path & "\" & oSubFolder.Name & "\", OverwriteExisting
Next


Only the good die young, me I'm here forever :)
 
Replace this:
transfer =Inputbox ("Enter folder containing files to transfer (TYPE or PASTE)")
By this:
Set Sh = CreateObject("Shell.Application")
Set F = Sh.BrowseForFolder(0, "Choose the folder containing files to transfer", 0, 17)
If F Is Nothing Then WSCript.Quit
transfer = F.Items.Item.Path

And this:
Path =Inputbox("Enter Target Folder (TYPE or PASTE)")
By this:
Set F = Sh.BrowseForFolder(0, "Choose Target Folder", 0, 17)
If F Is Nothing Then WSCript.Quit
Path = F.Items.Item.Path

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Well it now performs a browse to source and destination , but does not appear to do any thing with it. I think there is a fundemental problem with the Line < Folder = transfer & "\*" >
as this ( I now realalise does not acctually do any thing apart from direct the script to a folder I had called transfer! I assumed this part of the script was working when in fact the first part ie the Source lookup was all the time in the script. The end part that asks where to put it works so I have a long way to go....
Stressed School tech

Only the good die young, me I'm here forever :)
 
Well I have a working script, thanks PHV. It lets me browse to a folder, select a dolder containing subfolders and then browse to a destination and it will paste the contents into the subfolders. Its Great and will save me loads of work Thanks again!

Only the good die young, me I'm here forever :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top