• Problem : BrowseForFolder returns "The system cannot find the file specified"

    From R.Wieser@address@is.invalid to alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general on Tue Dec 16 11:26:17 2025
    From Newsgroup: alt.windows7.general

    Hello all,

    XPsp3

    I have the need to select a file, and found "BrowseFolFolder" should be able to do it.

    The problem is that no matter the path or the file selected, all I get is a "The system cannot find the file specified" error.

    The stripped-down example :

    - - - - - - - - - - - - - -
    Set shell = CreateObject("Shell.Application")
    call shell.BrowseForFolder(0, "Choose a file:", &H4000, "c:\")
    - - - - - - - - - - - - - -

    I do not see what might be going wrong here. Help ?

    Regards,
    Rudy Wieser


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Paul@nospam@needed.invalid to alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general on Tue Dec 16 07:53:06 2025
    From Newsgroup: alt.windows7.general

    On Tue, 12/16/2025 5:26 AM, R.Wieser wrote:
    Hello all,

    XPsp3

    I have the need to select a file, and found "BrowseFolFolder" should be able to do it.

    The problem is that no matter the path or the file selected, all I get is a "The system cannot find the file specified" error.

    The stripped-down example :

    - - - - - - - - - - - - - -
    Set shell = CreateObject("Shell.Application")
    call shell.BrowseForFolder(0, "Choose a file:", &H4000, "c:\")
    - - - - - - - - - - - - - -

    I do not see what might be going wrong here. Help ?

    Regards,
    Rudy Wieser



    When presented with your code, CoPilot sez:

    This code selects a folder.

    Set shell = CreateObject("Shell.Application")
    Set folder = shell.BrowseForFolder(0, "Choose a folder:", &H4000, "c:\")

    This code selects a file. We'll see in a moment, what the Copilot is up to.

    Set dialog = CreateObject("UserAccounts.CommonDialog")
    dialog.Filter = "All Files|*.*"
    dialog.FilterIndex = 1
    dialog.InitialDir = "C:\"
    dialog.ShowOpen

    *******

    This is supposed to be a more complete example, according to the CoPilot.

    ' Create the CommonDialog object
    Set dlg = CreateObject("UserAccounts.CommonDialog")

    ' Set filter (optional)
    dlg.Filter = "All Files|*.*|Text Files|*.txt|Images|*.jpg;*.png"

    ' Set initial directory (optional)
    dlg.InitialDir = "C:\"

    ' Show the Open dialog
    result = dlg.ShowOpen

    ' If user selected a file
    If result <> 0 Then
    WScript.Echo "You chose: " & dlg.FileName
    Else
    WScript.Echo "No file selected."
    End If


    Paul

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general on Tue Dec 16 14:26:30 2025
    From Newsgroup: alt.windows7.general

    Paul,

    When presented with your code, CoPilot sez:

    This code selects a folder.

    Set shell = CreateObject("Shell.Application")
    Set folder = shell.BrowseForFolder(0, "Choose a folder:", &H4000, "c:\")

    Than its hallucinating. The &H4000 means "The browse dialog box displays files as well as folders.". Which it does.

    This code selects a file. We'll see in a moment, what the Copilot is up
    to.

    Set dialog = CreateObject("UserAccounts.CommonDialog")
    dialog.Filter = "All Files|*.*"
    dialog.FilterIndex = 1
    dialog.InitialDir = "C:\"
    dialog.ShowOpen

    Damn. Before posting I googed for a VBScript file-selection copability, and did not see that one come by. :-\

    But, I just tested if it would work for me, and it does. So, thank you. :-)

    I have to say, I didn't even know about the existance of that "UserAccounts" object. Something to look into (new stuff and all that).

    Regards,
    Rudy Wieser


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From David E. Ross@nobody@nowhere.invalid to alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general on Tue Dec 16 08:54:37 2025
    From Newsgroup: alt.windows7.general

    On 12/16/2025 2:26 AM, R.Wieser wrote:
    Hello all,

    XPsp3

    I have the need to select a file, and found "BrowseFolFolder" should be able to do it.

    The problem is that no matter the path or the file selected, all I get is a "The system cannot find the file specified" error.

    The stripped-down example :

    - - - - - - - - - - - - - -
    Set shell = CreateObject("Shell.Application")
    call shell.BrowseForFolder(0, "Choose a file:", &H4000, "c:\")
    - - - - - - - - - - - - - -

    I do not see what might be going wrong here. Help ?

    Regards,
    Rudy Wieser

    Creating your own script is like creating the wheel when it already
    exists. Instead, try the Everything application from <https://www.voidtools.com/>.
    --

    David E. Ross
    <http:www.rossde.com>

    Some Republican officials have denounced the assassination
    of Charlie Kirk as a conspiracy by liberal Democrats. Why
    then is the attempted kidnapping of the Democrat governor
    of Michigan, the shooting of a Democrat state senator of
    Minnesota, and the assassination of the Democrat speaker
    of the Minnesota state assembly not denounced as a
    conservative Republican conspiracy?

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Paul@nospam@needed.invalid to alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general on Tue Dec 16 12:05:09 2025
    From Newsgroup: alt.windows7.general

    On Tue, 12/16/2025 11:54 AM, David E. Ross wrote:
    On 12/16/2025 2:26 AM, R.Wieser wrote:
    Hello all,

    XPsp3

    I have the need to select a file, and found "BrowseFolFolder" should be able
    to do it.

    The problem is that no matter the path or the file selected, all I get is a >> "The system cannot find the file specified" error.

    The stripped-down example :

    - - - - - - - - - - - - - -
    Set shell = CreateObject("Shell.Application")
    call shell.BrowseForFolder(0, "Choose a file:", &H4000, "c:\")
    - - - - - - - - - - - - - -

    I do not see what might be going wrong here. Help ?

    Regards,
    Rudy Wieser

    Creating your own script is like creating the wheel when it already
    exists. Instead, try the Everything application from <https://www.voidtools.com/>.


    But, you receive fine craftsmanship when you do it yourself :-)

    Paul

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general on Tue Dec 16 19:58:22 2025
    From Newsgroup: alt.windows7.general

    David,

    Creating your own script is like creating the wheel when it already
    exists.

    Thats a bold statement from someone who doesn't have the slightest idea of what I'm writing.

    A trolling troll is trolling I take it. :-p

    Regards,
    Rudy Wieser


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From JJ@jj4public@gmail.com to alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general on Wed Dec 17 09:15:18 2025
    From Newsgroup: alt.windows7.general

    On Tue, 16 Dec 2025 11:26:17 +0100, R.Wieser wrote:
    Hello all,

    XPsp3

    I have the need to select a file, and found "BrowseFolFolder" should be able to do it.

    The problem is that no matter the path or the file selected, all I get is a "The system cannot find the file specified" error.

    The stripped-down example :

    - - - - - - - - - - - - - -
    Set shell = CreateObject("Shell.Application")
    call shell.BrowseForFolder(0, "Choose a file:", &H4000, "c:\")
    - - - - - - - - - - - - - -

    I do not see what might be going wrong here. Help ?

    Are you sure the error occurs within that two lines?
    Did the dialog manage to be shown in the first place?
    Did it occur during the file selection while the dialog is shown?
    Did it occur after pressing the OK button?
    Did BrowseForFolder manage to return at all?
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general on Wed Dec 17 07:17:15 2025
    From Newsgroup: alt.windows7.general

    JJ,

    Are you sure the error occurs within that two lines?

    Yes. And even rather sure it happens in that last line, as its the line the error-mesage reports.

    Did the dialog manage to be shown in the first place?

    Yes.

    Did it occur during the file selection while the dialog is shown?

    No.

    Did it occur after pressing the OK button?

    Yes.

    Did BrowseForFolder manage to return at all?

    I've got no way to tell. I click OK, the dialog disappears and the error message pops up (or gets written to the console), after which the script is aborted.

    I /assume/ all of that happens in BrowseForFolder method itself, but
    ofcourse /could/, even if its not likely, be happening afterwards, just
    before the next line.

    Regards,
    Rudy Wieser



    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general on Wed Dec 17 09:04:31 2025
    From Newsgroup: alt.windows7.general

    JJ,

    [quote=me]
    The problem is that no matter *the path or* the file selected, all I get is
    a "The system cannot find the file specified" error.
    [/quote]
    (bolding mine)

    Re-testing just now (I was trying out some "Rob van der Woude" code*, adding the &H4000 flag) I noticed that its just the file selection which throws the error. A folder selection seems to work alright.

    My apologies for the mis-information.

    * https://stackoverflow.com/questions/4386124/how-can-i-use-the-common-save-as-dialog-from-vbscript

    Regards,
    Rudy Wieser


    --- Synchronet 3.21a-Linux NewsLink 1.2