Workarounds for Common Dialogs in WSH - Useful alternatives
(Page 2 of 4 )
You probably remember me stating that the Microsoft’s Common Dialogs control is a licensed control and cannot be used on machines that do not have a Development license installed. Since most don’t, we’re forced to find a workaround.
You should also remember me saying that programs created on these machines can use the control. That’s leaves us one more possible workaround—using a third-party program or control that was developed on a machine with a developer license.
There are a few of these available. Most of them are ActiveX controls that work as wrappers. A wrapper simply takes a request and passes it on to the Common Dialog control on our behalf.
The down side to this approach is that you will need to distribute the third-party control with your script and it will need to be installed on each machine as well. Installation is as simple as a service registration, but it’s still a hassle.
JSWare has released several freeware controls that you may find useful. Many of them also include a Common Dialogs wrapper.
In this example, I’m going to use JSWare’s JSDlgBox.dll. Once you download and register it, you can access it like any other COM object with its ProgID.
Set objDialogs = CreateObject("JSDlgBox.Browser")
WScript.Echo objDialogs.OpenBox
The syntax is very simple. After connecting to the JSDlgBox object, you only need to call the function for whichever dialog you wish to display. No parameters are necessary.
Set objDialogs = CreateObject("JSDlgBox.Browser")
WScript.Echo objDialogs.SaveBox
Both functions return empty strings if the user presses the Cancel button, and both also use the standard All Files filter.
While it is slightly restrictive when it comes to providing control over the dialogs, the JSDlgBox control does provide a very easy method of accessing the Common Dialogs control.
Next: The Browse For Folder dialog >>
More Windows Scripting Articles
More By Nilpo/Developer Shed Staff Writer