473,395 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Browse for file dialog box - modification needed

Hello all. Consider the following HTA:

<HTML>
<HEAD>
<TITLE></TITLE></HEAD>
<BODY>

<SCRIPT LANGUAGE="VBScript">
Sub ButBrowse_onclick()
'-- show browse window and Get file path:
Dim sFile
sFile = Browse
If (sFile <"") Then
'--Do something with file....
MsgBox sFile '--For demo
End If
End Sub

Function Browse()
Dim Q2, sRet, IE
On Error Resume Next
Q2 = chr(34)
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = False
IE.Navigate("about:blank")
Do Until IE.ReadyState = 4
Loop

IE.Document.Write "<HTML><BODY><INPUT ID=" & _
Q2 & "Fil" & Q2 & "Type=" & Q2 & "file" & Q2 & _
"></BODY></HTML>"
With IE.Document.all.Fil
.focus
.click
Browse = .value
End With
IE.Quit
Set IE = Nothing
End Function

</SCRIPT>

<INPUT NAME="ButBrowse" TYPE="button" TITLE="Browse to select file."
VALUE="Browse For File"></INPUT><BR>

</BODY></HTML>

I obtained the above script from a previous post:

http://groups.google.com/group/micro...C+IE%22&qt_g=1

By default the browse for file dialog box opens up to my workstation's
C: drive. I would like the ability to pre-select which drive and folder
the dialog box opens up to. If I run the script from a network drive
for example, I would like the dialog box to open up to that network
drive's current folder. Any suggestions would be greatly appreciated.
Thanks!

- Dave

Aug 30 '06 #1
3 11060

Highlander wote:
Hello all. Consider the following HTA:

<HTML>
<HEAD>
<TITLE></TITLE></HEAD>
<BODY>

<SCRIPT LANGUAGE="VBScript">
Sub ButBrowse_onclick()
'-- show browse window and Get file path:
Dim sFile
sFile = Browse
If (sFile <"") Then
'--Do something with file....
MsgBox sFile '--For demo
End If
End Sub

Function Browse()
Dim Q2, sRet, IE
On Error Resume Next
Q2 = chr(34)
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = False
IE.Navigate("about:blank")
Do Until IE.ReadyState = 4
Loop

IE.Document.Write "<HTML><BODY><INPUT ID=" & _
Q2 & "Fil" & Q2 & "Type=" & Q2 & "file" & Q2 & _
"></BODY></HTML>"
With IE.Document.all.Fil
.focus
.click
Browse = .value
End With
IE.Quit
Set IE = Nothing
End Function

</SCRIPT>

<INPUT NAME="ButBrowse" TYPE="button" TITLE="Browse to select file."
VALUE="Browse For File"></INPUT><BR>

</BODY></HTML>

I obtained the above script from a previous post:

http://groups.google.com/group/micro...C+IE%22&qt_g=1

By default the browse for file dialog box opens up to my workstation's
C: drive. I would like the ability to pre-select which drive and folder
the dialog box opens up to. If I run the script from a network drive
for example, I would like the dialog box to open up to that network
drive's current folder. Any suggestions would be greatly appreciated.
Thanks!
I seriously doubt you can do this, but you might want to talk to a
javascript group to see if they might have a solution. Here's some
interesting reading detailing why the browser behaves the way it does:
<http://www.cs.tut.fi/~jkorpela/forms/file.html>
--
Adrienne Boswell at work
Administrator nextBlock.com
http://atlas.nextblock.com/files/
Please respond to the group so others can share

Aug 30 '06 #2
In Windows XP at least, the dialog box default folder comes from the
registry key
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\ComDlg32\OpenSaveMRU\*.
There's a value there named MRUList that contains a list of lowercase
letters. The first letter in the list is the one you're interested in. So if
the first letter is the letter a, then you want to look at the value
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\ComDlg32\OpenSaveMRU\a.
It contains a path to a file. The directory that the file is in should
correspond to the directory in the browse box. So modifying the value of
that key to the directory that you want should change the directory that the
file browser starts in.

"Highlander" <tr******@msn.comwrote in message
news:11*********************@74g2000cwt.googlegrou ps.com...
: Hello all. Consider the following HTA:
:
: <HTML>
: <HEAD>
: <TITLE></TITLE></HEAD>
: <BODY>
:
: <SCRIPT LANGUAGE="VBScript">
: Sub ButBrowse_onclick()
: '-- show browse window and Get file path:
: Dim sFile
: sFile = Browse
: If (sFile <"") Then
: '--Do something with file....
: MsgBox sFile '--For demo
: End If
: End Sub
:
: Function Browse()
: Dim Q2, sRet, IE
: On Error Resume Next
: Q2 = chr(34)
: Set IE = CreateObject("InternetExplorer.Application")
: IE.visible = False
: IE.Navigate("about:blank")
: Do Until IE.ReadyState = 4
: Loop
:
: IE.Document.Write "<HTML><BODY><INPUT ID=" & _
: Q2 & "Fil" & Q2 & "Type=" & Q2 & "file" & Q2 & _
: "></BODY></HTML>"
: With IE.Document.all.Fil
: .focus
: .click
: Browse = .value
: End With
: IE.Quit
: Set IE = Nothing
: End Function
:
: </SCRIPT>
:
: <INPUT NAME="ButBrowse" TYPE="button" TITLE="Browse to select file."
: VALUE="Browse For File"></INPUT><BR>
:
: </BODY></HTML>
:
: I obtained the above script from a previous post:
:
:
http://groups.google.com/group/micro...C+IE%22&qt_g=1
:
: By default the browse for file dialog box opens up to my workstation's
: C: drive. I would like the ability to pre-select which drive and folder
: the dialog box opens up to. If I run the script from a network drive
: for example, I would like the dialog box to open up to that network
: drive's current folder. Any suggestions would be greatly appreciated.
: Thanks!
:
: - Dave
:
Aug 30 '06 #3

"Walter Zackery" <pl***************@group.comwrote in message
news:uo**************@TK2MSFTNGP02.phx.gbl...
: In Windows XP at least, the dialog box default folder comes from the
: registry key
:
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\ComDlg32\OpenSaveMRU\*.
: There's a value there named MRUList that contains a list of lowercase
: letters. The first letter in the list is the one you're interested in. So
if
: the first letter is the letter a, then you want to look at the value
:
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\ComDlg32\OpenSaveMRU\a.
: It contains a path to a file. The directory that the file is in should
: correspond to the directory in the browse box. So modifying the value of
: that key to the directory that you want should change the directory that
the
: file browser starts in.
:
The above contains a typo. Instead of
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\ComDlg32\OpenSaveMRU\a
, I should written
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\ComDlg32\OpenSaveMRU\*\a
Aug 30 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: strutsng | last post by:
<input type="file"> only allows the user to browse for files. How about "browse for folder" dialog? Can html/javascript do that? I couldn't find any syntax for that. If not, please advise what...
5
by: Rob | last post by:
Help me, I'm just beginning with programming in Access 2000. I've tried the http://www.mvps.org/access/api/api0001.htm but it won't work in Access. What am i doing wrong. I don't have...
5
by: deko | last post by:
I'm using the below code to allow users to browse for and select a folder. After selecting a folder from the dialog, the full path is returned to a text box and saved. The next time the user...
5
by: Eric Twietmeyer | last post by:
Hi, Does anyone know why starting with VS.NET 2002 (and same with 2003) it is no longer possible to browse to a directory that has "ept" as part of the path? It worked fine in Vc 6.x. My...
3
by: oopaevah | last post by:
I want to have a separate button which invokes the "browse" button on an input type=file. In internet explorer the following code works ok, in firefox nothing happens. All I do is call click()...
4
by: rdemyan | last post by:
I'm using code from the following web page to open the API Browse Folder dialog http://www.mvps.org/access/api/api0002.htm It all works fine. But if the dialog box is open and the user closes...
4
by: developing | last post by:
Hi All, I have a browse button that the user can click to select a file. The button then fetches the file path. This is all working fine except my boss wants some add functionality. I need it to...
1
by: developing | last post by:
Hello, This time I want to filter the 'browse for file' API so that certain drives/folders cant be accessed. Not sure how to go about this...here is the module I am currently using to browse...
3
by: ApexData | last post by:
I am using code from the following links to establish a Browse File and Browse Folder dialog. http://www.mvps.org/access/api/api0001.htm http://www.mvps.org/access/api/api0002.htm This code...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.