mr_unreliable
Mon Jun 27 15:33:39 CDT 2005
This is a multi-part message in MIME format.
--------------010904060408020004030306
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
As was previously mentioned, there are some third-party controls out there
which may be used to show an openfile dialog.
Of course, this is not "pure" script. On-the-other-hand some of these
third party controls can do "more" for you than the "pure" script
methods.
After making that assertion, I thought I should go and find one.
The first place I looked was the Common Controls Replacement Project.
This a bunch of guys who are so arrogant that they think they can do
a better job of it than Microsoft. And, they generally succeed.
CCRP does have a file dialog control, but (sob!) it must be sited on
a form, and vbs ain't got no steekin' forms capability. For shame,
Microsoft!
Next, I looked at Steve McMahon's vbAccelerator site. Steve is another
guy that thinks he can do a better job of it than Microsoft also, and
he succeeds too. He even ties-one-hand-behind-his-back as well,
choosing to code stuff in vb that clearly ought to be coded in c++.
To get on with it, Steve has an actX object that will show an openfile
dialog from script, as well as all the other common dialogs (but that's
another story).
His object is called "Common Dialog Direct", which means that he is
generating the dialogs DIRECT-ly using api calls. The actX object is
found in his cmdlgd.dll, which you may download here:
http://www.vbaccelerator.com/home/VB/Code/Libraries/Common_Dialogs/Common_Dialog_Direct/VB5_Common_Dialog_Direct_Binary.asp
and a rather brief discussion of it can be found here:
http://www.vbaccelerator.com/home/VB/Code/Libraries/Common_Dialogs/Common_Dialog_Direct/article.asp
There is also a sample (vbs) script attached.
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
p.s. If you look carefully at cmdlgd.dll with a typelib tool, you will
find that Steve gives you access to the Microsoft dialogs as well --
and without a license. Look for "vbGetOpenFileName". But of course
to use it you will have to install Microsoft's ocx.
--------------010904060408020004030306
Content-Type: text/plain;
name="vbAccel_OpenFileDialogDemo.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="vbAccel_OpenFileDialogDemo.txt"
' demo showing openfile dialog, using vbAccelerator's commondialog object, jw 26June05
' (note: this object if found in the dmdlgd.dll)...
Dim oCD : Set oCD = WScript.CreateObject("CommonDialogDirect.cCommonDialog", "oCD_") ' with events
Const OFN_PATHMUSTEXIST = &H800
Const OFN_FILEMUSTEXIST = &H1000
'
Dim m_OpenClick : m_bOpenClick = False ' as boolean
Dim m_bDialogClosed : m_bDialogClosed = False ' as boolean
' --- end of declarations and constants ----------
With oCD ' set up parameters...
.DialogTitle = " < vbAccelerator OpenFile Dialog Demo (from Script) > "
' a string that can specify the initial directory.
' .InitDir = "c:\windows\"
' (note: a "virtual folder" may also be specified as: "::{clsid}")...
.InitDir = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" ' "My Computer"
' .InitDir = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" ' "My Documents"
' .InitDir = "::{645FF040-5081-101B-9F08-00AA002F954E}" ' "Recycle Bin"
.Flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST
' in THIS case, vertical bars are used to separate the various filters,
' as using the (system standard) "null" characters would cause vbs
' to "throw up"...
.Filter = "Internet documents (*.HTM)|*.HTM|Text files (*.TXT)|*.TXT|All Files (*.*)|*.*"
.FilterIndex = 3 ' one-based, (i.e., show all files)...
.HookDialog = True ' "hooking" means subclass to detect events...
End With
oCD.ShowOpen ' show the (openfile) dialog (modally)
' show the file name selected...
If (m_bOpenClick) then ' the selection was ok
MsgBox("you selected: " & vbCrLf & vbCrLf _
& " " & oCD.FileName)
ElseIf (m_bDialogClosed And Not m_bOpenClick) then
MsgBox("you clicked CANCEL -- (or CLOSE without selecting) ")
Else
MsgBox("unknown termination event -- fire your incompetent scripter!!! ")
End If
Set oCD = nothing
WScript.Quit
' --- EVENT HANDLERS -----------------------------
Sub oCD_DialogOK(bCancel) ' "OK" (i.e., "open" button clicked)
m_bOpenClick = True ' means passed path+file exists tests
' bCancel is a return value, which tells the dialog that
' this choice is not acceptable...
bCancel = False ' don't cancel
End Sub
Sub oCD_DialogClose()
' MsgBox("DialogClose_Event")
m_bDialogClosed = True
End Sub
--------------010904060408020004030306--