Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Common File Dialog for Vista

Status
Not open for further replies.

jasonp45

Programmer
Aug 23, 2001
212
US
I'm on 64-bit and I've found that the old MSComDlg.CommonDialog object can only be invoked under 32-bit. I can use the Word dialog but of course that requires installing Word, and creating the Word.Application object is slow.

What I'd like to know is how (or if) I can invoke a file-open/browse dialog with some open source object via VBScript. Clearly nearly every program does this, including open source (Firefox, FileZilla, etc.)

I guess the other thing would be a Windows API wrapper class. Anyway, does anyone have something like this? Thanks.
 
MSComDlg.CommonDialog is a licensed control.

You aren't permitted to just copy it wherever you feel like, so it should almost never be used in script. There are strict conditions that apply to use it at runtime. This is discussed in detail in articles such as Enhance Your Apps with Common Dialogs: Part I


There was the short-lived UserAccounts.CommonDialog in XP (only) but that won't help either.

The good news is that creating a thin wrapper DLL over the API calls is trivial in VB 5 or 6. The bad news is you need VB 5 or 6 and then you still have a component to deploy with your scripts.

However you might play with one of the versions of CommonDialog/Direct which are available in source and binary forms and should be unencumbered by license restrictions. Will they work in Vista64? You'll have to give it a shot and see.
 
Easiest solution I know of is to copy safrcdlg.dll from an XP system to the Vista install and register the DLL. A copy of the DLL is available for download from my site:


Code:
'==========================================================================
'
' NAME: fileBrowse.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 9/28/2004
'
' COMMENT: Use this snippet to allow a user to select a file.  This DLL was 
'          depricated in Windows Vista but works under Vista when registered.  
'          Copy the DLL and register it using REGSVR32.
'==========================================================================

set oFO = CreateObject("SAFRCFileDlg.FileOpen")
' browse to file name thanks to safrcdlg.dll
' DLL available for downlaod from:
' [URL unfurl="true"]http://www.thespidersparlor.com/publicdownloads/safrcdlg.zip[/URL]
oFO.OpenFileOpenDlg
' show what the user clicked on.
wscript.echo oFO.FileName

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top