Browsing for a folder 
Author Message
 Browsing for a folder

I have written some script that allows a user to browse for a folder. It
uses the Microsoft Internet Controls. ("Shell.Application")

My problem is that while the BrowseForFolder function returns a folder
object, I can't seem to get the path of the folder in any way. The title
property only returns the name of the folder, e.g. you browse for the folder
"c:\windows\profile," but the title appears as "profiles." Does anyone know
a way to get the full path to the folder, so that I can create a reference
to it as part of the "Scripting.FileSystemObject"? Also I can't find any
general information on this Control on MSDN or anywhere, although browsing
it with the VB Object Brower it seems to contain some very useful and
accessible functions.

Any help would be greatly appreciated!

Here is my code:

    '*******************************************
    '     Directory Browsing Script
    '*******************************************
    Dim objShell
    Set objShell = WScript.CreateObject("Shell.Application")

    Set objFolder = objShell.BrowseForFolder(&H0, "hello", &h10&)

    MsgBox objFolder.Title

Thanks,
Sen Hennessy



Tue, 06 Mar 2001 03:00:00 GMT  
 Browsing for a folder
Ian Morrish has the following script in his WSHFAQ
(http://wsh.glazier.co.nz ), which isn't quite the same, but can do the job:
---
on error resume next
set WSHShell = wscript.CreateObject("wscript.Shell")
  set objDlg = wscript.CreateObject("MSComDlg.CommonDialog")
  objDlg.Filter = "All Files (*.*)|*.*|VBScript Files (*.vbs)|*.vbs"
  objDlg.FilterIndex = 2
  objDlg.MaxFileSize = 260
  objDlg.CancelError = true
  objDlg.ShowOpen
WSHShell.popup objDlg.Filename
---

Quote:

>I have written some script that allows a user to browse for a folder. It
>uses the Microsoft Internet Controls. ("Shell.Application")

>My problem is that while the BrowseForFolder function returns a folder
>object, I can't seem to get the path of the folder in any way. The title
>property only returns the name of the folder, e.g. you browse for the
folder
>"c:\windows\profile," but the title appears as "profiles." Does anyone know
>a way to get the full path to the folder, so that I can create a reference
>to it as part of the "Scripting.FileSystemObject"? Also I can't find any
>general information on this Control on MSDN or anywhere, although browsing
>it with the VB Object Brower it seems to contain some very useful and
>accessible functions.

>Any help would be greatly appreciated!

>Here is my code:

>    '*******************************************
>    '     Directory Browsing Script
>    '*******************************************
>    Dim objShell
>    Set objShell = WScript.CreateObject("Shell.Application")

>    Set objFolder = objShell.BrowseForFolder(&H0, "hello", &h10&)

>    MsgBox objFolder.Title

>Thanks,
>Sen Hennessy



Tue, 06 Mar 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Browsing for a folder - cracked it!

2. Browse for folder

3. Browse for folder

4. Browse for folder, open/save file

5. Browse.WshKit Won't Work On Folders Names with Spaces

6. browse for folder or file

7. Browse folder path

8. Browse for folder?

9. Browse for folder?

10. Browse for Folder C drive

11. Browsing Outlook folders with Windows Scripting

12. browse for folder or file

 

 
Powered by phpBB® Forum Software