0

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?

2
  • Try Set oDialog = CreateObject("UserAccounts.CommonDialog"). Preset oDialog.Filter and oDialog.InitialDir properties and invoke intResult = oDialog.ShowOpen. Then, if intResult is non-zero, check oDialog.FileName property Commented Nov 24, 2014 at 1:09
  • CreateObject("UserAccounts.CommonDialog") only works xp? So it looks like. Commented Nov 24, 2014 at 1:17

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.