How to make a simple file dialog on Windows 7?

Trevor picture Trevor · Nov 24, 2014 · Viewed 11.1k times · Source

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?

Answer

Trevor picture Trevor · Nov 24, 2014

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.