Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Thu, 13 Sep 2007 07:24:04 -0700,    group: microsoft.public.inetsdk.programming.scripting.vbscript        back       


Retrieve file name from BrowseForFolder   
Hi.
Can anyone tell me how I can retrieve the file name when I use the 
BrowseForFolder object? I have set two options on the BrowseForFolder: 1) 
file names are displayed and 2) edit - in case they want to type in a new 
file name. I can retrieve a folder name but not the file name. It is not 
abending. My code is picking it up in the 'Unknown error-1' section. If 
anyone can tell me how to do this, I would be very grateful. Here is my code:
--------------
On Error Resume Next

' Flags for the options parameter
Const BIF_returnonlyfsdirs   = &H0001
Const BIF_dontgobelowdomain  = &H0002
Const BIF_statustext         = &H0004
Const BIF_returnfsancestors  = &H0008
Const BIF_editbox            = &H0010
Const BIF_validate           = &H0020
Const BIF_browseforcomputer  = &H1000
Const BIF_browseforprinter   = &H2000
Const BIF_browseincludefiles = &H4000

Dim file, oShell, oItem, tmp, msg

Set oShell = CreateObject("Shell.Application")
Set oItem = oShell.BrowseForFolder(&H0, "Select a file or folder", 
BIF_editbox + BIF_browseincludefiles, "")

If Err.Number <> 0 Then
    If Err.Number = 5 Then
        msg = "root folder error"
    else
        msg = "Unknown error-1"
    End If
Else
    file = oItem.self.path
    If Err<> 0 Then
        If Err.Number = 424 Then
            msg = "Cancel clicked"
        Else
            msg = "Unknown error-2"
        End If
    Else
	msg = file
    End If 
End if

Set oShell = Nothing
Set oItem = Nothing
---------- 
Thanks!!
Karin
date: Thu, 13 Sep 2007 07:24:04 -0700   author:   Karin

RE: Retrieve file name from BrowseForFolder   
Hi
yo can use 
Set folder = cosa.BrowseForFolder(&H0, "Seleccione el archivo", BIF_editbox 
+ BIF_browseincludefiles, "")
Wscript.echo folder.Self.Path

If you would like to see the properties and methods...bla bla yo can 
create un proyect in Visual Basic and to agregate the file shell32.dll like 
a reference:

Option Explicit
' Flags for the options parameter
Option Explicit
Const BIF_returnonlyfsdirs = &H1
Const BIF_dontgobelowdomain = &H2
Const BIF_statustext = &H4
Const BIF_returnfsancestors = &H8
Const BIF_editbox = &H10
Const BIF_validate = &H20
Const BIF_browseforcomputer = &H1000
Const BIF_browseforprinter = &H2000
Const BIF_browseincludefiles = &H4000

Private Sub Form_Load()
Dim objShell As Shell32.Shell
Dim objFolder As Shell32.Folder2
Set objShell = New Shell32.Shell

Set objFolder = objShell.BrowseForFolder(&H0, "Select the file", _
                BIF_editbox + BIF_browseincludefiles, "")
MsgBox objFolder.Self.Path & " " & _
       objFolder.Self.IsFolder & " " & _
       objFolder.Self.IsLink & " " & _
       objFolder.Self.Name & " "

End Sub

And in VBScript you can use:
Option Explicit
Const BIF_returnonlyfsdirs = &H1
Const BIF_dontgobelowdomain = &H2
Const BIF_statustext = &H4
Const BIF_returnfsancestors = &H8
Const BIF_editbox = &H10
Const BIF_validate = &H20
Const BIF_browseforcomputer = &H1000
Const BIF_browseforprinter = &H2000
Const BIF_browseincludefiles = &H4000

Dim objShell As Shell32.Shell
Dim objFolder As Shell32.Folder2
Set objShell = New Shell32.Shell

Set objFolder = objShell.BrowseForFolder(&H0, "Select the file", _
                BIF_editbox + BIF_browseincludefiles, "")
MsgBox objFolder.Self.Path & " " & _
       objFolder.Self.IsFolder & " " & _
       objFolder.Self.IsLink & " " & _
       objFolder.Self.Name & " "




"Karin" wrote:

> Hi.
> Can anyone tell me how I can retrieve the file name when I use the 
> BrowseForFolder object? I have set two options on the BrowseForFolder: 1) 
> file names are displayed and 2) edit - in case they want to type in a new 
> file name. I can retrieve a folder name but not the file name. It is not 
> abending. My code is picking it up in the 'Unknown error-1' section. If 
> anyone can tell me how to do this, I would be very grateful. Here is my code:
> --------------
> On Error Resume Next
> 
> ' Flags for the options parameter
> Const BIF_returnonlyfsdirs   = &H0001
> Const BIF_dontgobelowdomain  = &H0002
> Const BIF_statustext         = &H0004
> Const BIF_returnfsancestors  = &H0008
> Const BIF_editbox            = &H0010
> Const BIF_validate           = &H0020
> Const BIF_browseforcomputer  = &H1000
> Const BIF_browseforprinter   = &H2000
> Const BIF_browseincludefiles = &H4000
> 
> Dim file, oShell, oItem, tmp, msg
> 
> Set oShell = CreateObject("Shell.Application")
> Set oItem = oShell.BrowseForFolder(&H0, "Select a file or folder", 
> BIF_editbox + BIF_browseincludefiles, "")
> 
> If Err.Number <> 0 Then
>     If Err.Number = 5 Then
>         msg = "root folder error"
>     else
>         msg = "Unknown error-1"
>     End If
> Else
>     file = oItem.self.path
>     If Err<> 0 Then
>         If Err.Number = 424 Then
>             msg = "Cancel clicked"
>         Else
>             msg = "Unknown error-2"
>         End If
>     Else
> 	msg = file
>     End If 
> End if
> 
> Set oShell = Nothing
> Set oItem = Nothing
> ---------- 
> Thanks!!
> Karin
date: Wed, 28 Nov 2007 20:59:00 -0800   author:   Edward López Garbanzo Edward L?pez

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us