TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
Browse For File Dialog in Vista
Thursday, September 16, 2010 10:30 PM
( permalink)
I had insomnia last night, so I wrote a function to resolve the dreaded file dialog issue in Windows Vista and Windows 7: Function BrowseForFile()
Dim shell : Set shell = CreateObject("WScript.Shell")
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
Dim tempName : tempName = fso.GetTempName()
Dim tempFile : Set tempFile = tempFolder.CreateTextFile(tempName & ".hta")
tempFile.Write _
"<html>" & _
" <head>" & _
" <title>Browse</title>" & _
" </head>" & _
" <body>" & _
" <input type='file' id='f'>" & _
" <script type='text/javascript'>" & _
" var f = document.getElementById('f');" & _
" f.click();" & _
" var shell = new ActiveXObject('WScript.Shell');" & _
" shell.RegWrite('HKEY_CURRENT_USER\\Volatile Environment\\MsgResp', f.value);" & _
" window.close();" & _
" </script>" & _
" </body>" & _
"</html>"
tempFile.Close
shell.Run tempFolder & "\" & tempName & ".hta", 1, True
BrowseForFile = shell.RegRead("HKEY_CURRENT_USER\Volatile Environment\MsgResp")
shell.RegDelete "HKEY_CURRENT_USER\Volatile Environment\MsgResp"
End Function
MsgBox BrowseForFile Feedback is welcome of course.
<message edited by TNO on Tuesday, October 26, 2010 12:16 PM>
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
Re:Browse For File Dialog in Vista
Tuesday, October 26, 2010 12:17 PM
( permalink)
Hooray, the forum is "fixed". Code copied from pastebin...
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
jloyzaga
-
Total Posts
:
77
- Scores: 0
-
Reward points
:
0
- Joined: 9/24/2007
-
Status: offline
|
Re:Browse For File Dialog in Vista
Friday, May 06, 2011 7:03 PM
( permalink)
so that looks for a *.hta set of files? how can I get all .xls files? tried changing .hta to xls and it couldn't find any? is it because it looks for it only in the c:\programfile\vbsedit folder?
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
Re:Browse For File Dialog in Vista
Friday, May 06, 2011 8:02 PM
( permalink)
No, it opens a browse dialog using an hta file to bypass the browser's security. There is no native filter for the file type. All files are browsed for as is done normally through Windows Explorer
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
jloyzaga
-
Total Posts
:
77
- Scores: 0
-
Reward points
:
0
- Joined: 9/24/2007
-
Status: offline
|
Re:Browse For File Dialog in Vista
Saturday, May 07, 2011 8:38 AM
( permalink)
so why is it only showing the files in the native vbsedit directory?" how can I filter it and run against a specific folder?
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
Re:Browse For File Dialog in Vista
Saturday, May 07, 2011 10:57 AM
( permalink)
If you run the file from the desktop, it'll open a dialog from there. If you run it from c:\, the dialog will display from there. Using this approach you are at the mercy of what the behavior <input type="file"> supports: http://msdn.microsoft.com...5263%28v=vs.85%29.aspx
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
mogoo
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 2/24/2012
- Location: Calif
-
Status: offline
|
Re:Browse For File Dialog in Vista
Friday, February 24, 2012 10:16 AM
( permalink)
TNO - thank you for this excellent script. I noticed that running this returns the mapped drive path. Since I've no real experience with HTA how could this be modified to return the UNC path and file name? tia
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
Re:Browse For File Dialog in Vista
Friday, February 24, 2012 5:58 PM
( permalink)
mogoo TNO - thank you for this excellent script. I noticed that running this returns the mapped drive path. Since I've no real experience with HTA how could this be modified to return the UNC path and file name? tia Just browse through the "Network" folder instead of the drive
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
mogoo
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 2/24/2012
- Location: Calif
-
Status: offline
|
Re:Browse For File Dialog in Vista
Saturday, February 25, 2012 7:13 AM
( permalink)
Thank you - once I added "Network" to the Favorite Links in Windows Explorer worked like a charm! Appreciate it!
|
|
|
|