hasnut
asked on
VBSCRIPT something link BrowseForFile as BrowseForFolder
Is there any way to display a "BrowseForFile" dialog, similar to the
BrowseForFolder method of the shell object? I am
looking for a way to allow the user to select a FILE or a FOLDER
Is this possible in VBScript?
BrowseForFolder method of the shell object? I am
looking for a way to allow the user to select a FILE or a FOLDER
Is this possible in VBScript?
ASKER
HI HI,
So, can I select Folder?
Option Explicit
Const SerSetRoot_desktop = 0
Const SerSetRoot_programs = 2
Const SerSetRoot_controlpanel = 3
Const SerSetRoot_printers = 4
Const SerSetRoot_documents = 5
Const SerSetRoot_favorites = 6
Const SerSetRoot_startup = 7
Const SerSetRoot_recent = 8
Const SerSetRoot_sendto = 9
Const SerSetRoot_startmenu = 11
Const SerSetRoot_drives = 17
Const SerSetRoot_network = 18
Const SerSetRoot_nethood = 19
Const SerSetRoot_fonts = 20
Const SerSetRoot_templates = 21
Code 1 End
Here in code 1 we see we can set root as we like. Those are the constant values.
Code 2 Starts
Function BrowseForAnything(ShowText , BrowseInformation, SetRoot)
On Error Resume Next
Dim AppShell, ReturnFolder, WshShell, errorcode,ColonPosition
Set AppShell = WScript.CreateObject("Shel l.Applicat ion")
Set WshShell = CreateObject("WScript.Shel l")
Set ReturnFolder = AppShell.BrowseForFolder(& H0, ShowText, BrowseInformation, SetRoot)
BrowseForAnything = ReturnFolder.ParentFolder. ParseName( ReturnFold er.Title). Path
errorcode = err.number
If errorcode <> 0 Then
If errorcode = 424 then
BrowseForAnything = Null
else
ColonPosition = InStr(ReturnFolder.Title, ":")
If ColonPosition > 0 Then
BrowseForAnything = Mid(ReturnFolder.Title, ColonPosition - 1, 2) & "\"
End If
End If
End If
End Function
I need: if file is selected then return value should be the file path+file name
if directory selected then show the Directory/folder path (ITS ALLREADY THERE)
So, can I select Folder?
Option Explicit
Const SerSetRoot_desktop = 0
Const SerSetRoot_programs = 2
Const SerSetRoot_controlpanel = 3
Const SerSetRoot_printers = 4
Const SerSetRoot_documents = 5
Const SerSetRoot_favorites = 6
Const SerSetRoot_startup = 7
Const SerSetRoot_recent = 8
Const SerSetRoot_sendto = 9
Const SerSetRoot_startmenu = 11
Const SerSetRoot_drives = 17
Const SerSetRoot_network = 18
Const SerSetRoot_nethood = 19
Const SerSetRoot_fonts = 20
Const SerSetRoot_templates = 21
Code 1 End
Here in code 1 we see we can set root as we like. Those are the constant values.
Code 2 Starts
Function BrowseForAnything(ShowText
On Error Resume Next
Dim AppShell, ReturnFolder, WshShell, errorcode,ColonPosition
Set AppShell = WScript.CreateObject("Shel
Set WshShell = CreateObject("WScript.Shel
Set ReturnFolder = AppShell.BrowseForFolder(&
BrowseForAnything = ReturnFolder.ParentFolder.
errorcode = err.number
If errorcode <> 0 Then
If errorcode = 424 then
BrowseForAnything = Null
else
ColonPosition = InStr(ReturnFolder.Title, ":")
If ColonPosition > 0 Then
BrowseForAnything = Mid(ReturnFolder.Title, ColonPosition - 1, 2) & "\"
End If
End If
End If
End Function
I need: if file is selected then return value should be the file path+file name
if directory selected then show the Directory/folder path (ITS ALLREADY THERE)
I have no idea what you are trying to do. I don't use vbscript. From what I can see though, if it runs at all on a web page it is going to throw all kind so security alerts and a lot of fire walls will block it.
If you are trying to preset the path the user goes to, you will have a hard time, because the browser has specific security routines to prevent that.
Cd&
If you are trying to preset the path the user goes to, you will have a hard time, because the browser has specific security routines to prevent that.
Cd&
ASKER
Just rename it vbs and run it. You will see the Browse for Folder Window, I have the asp code of this.
ASKER
INTERESTING NO ONE ANSWERING MY QUESTION? If anyone interested I can give you much big points
No, you cannot select a File in the same way that you select the folder. Trust me, I have spent a long time trying to do it. The best you could do is display a list of the files in the directory selected.
Dom
Dom
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<form>
<input type="file">
</form>
Cd&