none
Seeking help on HTA VBScript file selection dialogue script RRS feed

  • Question

  • HTA VBScript file selection dialogue script help
    ----------------------------------------
    i am working on a VBscript in which one of the requirement is to prompt user file/folder selection dialog and based on user selection, file/folder content will be copied.i am able to prompt user file/folder selection dialogue but facing challenging in reading user file selection path whereas i can read folder selection.
    Kindly guide where it went wrong or suggest if we have any other better way to achieve this requirement of user file/folder selection.

    folder selection code which is working:
    -----------------------------------------
    Function PickFolder(strStartDir)
    Dim SA, F
    Set SA = CreateObject("Shell.Application")
    Set F = SA.BrowseForFolder(0, "Choose a folder", 0 , strStartDir)
    If (Not F Is Nothing) Then 
     PickFolder = F.ParentFolder.ParseName(f.Title).Path

      'PickFolder = F.Items.Item.path
     End If
    Set F = Nothing
    Set SA = Nothing
    End Function


    File selection code in which i am getting error (unspecified error in line marked below):
    --------------------------------------------------------
    selectFile = PickFolder( _ 
           "Select a file. " & vbCrLf & _ 
        "Current starting folder path: ", &H0001+ &H4000,"")
     Function PickFolder(title, flag, dir) 
      'Function PickFolder(dir) 
        Dim SA, F, tmp
        Set SA = CreateObject("Shell.Application")
        Set F = SA.BrowseForFolder(&H0, title, flag, dir )
        'Set F = SA.BrowseForFolder(&H0, "Select file", &H0001+ &H4000, dir ) ----> Line which throws error
         
        'On Error Resume Next
        PickFolder = F.ParentFolder.ParseName(F.Title).Path
        If Err.Number <> 0 Then
                PickFolder = CStr(Err.Number)
                Exit Function
        End If
       
    End Function


    Nisajudeen

    Wednesday, May 9, 2018 7:08 PM

Answers

All replies