Search code examples
vbscriptwindows-7opendialog

How to make a simple file dialog on Windows 7?


I am trying to create a simple file select dialog in VBScript. I have searched around for and answer but not come up with a simple solution. I don't need Filter options or the like.

In extended script I would use myFile = File.openDialog().

Can someone give me the VBScript equivalent for Windows 7?


Solution

  • I found the below snippet using shell script over here https://gist.github.com/mlhaufe/1034241

    Function BrowseForFile()
    Dim shell : Set shell = CreateObject("Shell.Application")
    Dim file : Set file = shell.BrowseForFolder(0, "Choose a file:", &H4000)
    BrowseForFile = file.self.Path
    End Function 
    MsgBox BrowseForFile 
    

    It seems to work well. Interested if there's a simple "pure vbs" version.