Browse for file dialog box - modification needed

Discussion in 'HTML' started by Highlander, Aug 30, 2006.

  1. Highlander

    Highlander Guest

    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/micr...cripting.vbscript&q="Dim Q2, sRet, IE"&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
     
    Highlander, Aug 30, 2006
    #1
    1. Advertising

  2. 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/micr...cripting.vbscript&q="Dim Q2, sRet, IE"&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
     
    Adrienne Boswell, Aug 30, 2006
    #2
    1. Advertising

  3. In Windows XP at least, the dialog box default folder comes from the
    registry key
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\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\CurrentVersion\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" <> wrote in message
    news:...
    : 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/micr...cripting.vbscript&q="Dim Q2, sRet, IE"&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
    :
     
    Walter Zackery, Aug 30, 2006
    #3
  4. "Walter Zackery" <> wrote in message
    news:...
    : In Windows XP at least, the dialog box default folder comes from the
    : registry key
    :
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\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\CurrentVersion\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\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\a
    , I should written
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\*\a
     
    Walter Zackery, Aug 30, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anita C

    Browse File dialog

    Anita C, Nov 27, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,953
    Anita C
    Dec 1, 2003
  2. FlashT

    Browse file dialog box...

    FlashT, Apr 8, 2005, in forum: HTML
    Replies:
    1
    Views:
    724
    David Dorward
    Apr 9, 2005
  3. =?Utf-8?B?ZGVuIDIwMDU=?=

    Getting File Path in Browse File Dialog in ASP.Net

    =?Utf-8?B?ZGVuIDIwMDU=?=, May 5, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    10,633
    =?Utf-8?B?ZGVuIDIwMDU=?=
    May 8, 2006
  4. Jen
    Replies:
    4
    Views:
    262
    Alessandro Zifiglio
    Feb 12, 2004
  5. Replies:
    0
    Views:
    242
Loading...

Share This Page