![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | VBScript, HTA and CommonDialog in PE I'm working on a project in WinPE and am using an HTA with vbscript in it. Everything works great in WinPE, except a call to MSComDlg.CommonDialog for saving and opening files. These calls work in Vista x86 Business, but I can't get them to work in PE. I've brought over and registered both the Comdlg32.ocx and Comdlg32.dll, I still get the notice about ActiveX component can't create object for the MScomdlg. I have the scripting, hta, and xml packages installed on the PE image. Any help in this matter would be appreciated. The code in question is as follows: <script for="begin" event="OnClick" language="vbscript"> //dim capdep, syst, fileLoc If StrComp(document.getElementByID("protype").value,"") = 0 Then MsgBox "Error: No action Chosen" ElseIf StrComp(document.getElementByID("promodel").value,"") = 0 Then MsgBox "Error: Choose a Model" Else Set objDialog = CreateObject("MSComDlg.CommonDialog") objDialog.MaxFileSize = 260 objDialog.InitDir = "z:\" & document.getElementByID("promodel").value objDialog.Filter = "Image Files|*.wim" objDialog.Flags = &H80000 AND &H2 objDialog.FilterIndex = 1 If StrComp(document.getElementByID("protype").value,"Capture") = 0 Then objDialog.ShowSave capdep = "cap" Else objDialog.Flags = objDialog.Flags AND &H1000 objDialog.ShowOpen capdep = "dep" End If Etc.. I don't know what i'm missing to get the MSComDlg to work in WinPE |
My System Specs![]() |
| | #2 (permalink) |
| | Re: VBScript, HTA and CommonDialog in PE hbasselet@xxxxxx wrote: Quote: > I'm working on a project in WinPE and am using an HTA with vbscript in > it. Everything works great in WinPE, except a call to > MSComDlg.CommonDialog for saving and opening files. It could be a matter of licensing. For example, if you have a vb5/6 compiler installed, then the commondialog actX component will be licensed on your system. I am surprised that you are not getting an error diagnostic to the effect that a license is required to use the component. There are other ways (and other components) which you can use to implement an open/saveas dialog. You can find the other (scripting) methods to use the open/saveas dialogs in this ng, by using google advanced group search. And you can find other actX components by just googling, or you can write one yourself. cheers, jw ____________________________________________________________ You got questions? WE GOT ANSWERS!!! ..(but, no guarantee the answers will be applicable to the questions) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: another open/saveas dialog component... mr_unreliable wrote: Quote: > There are other ways (and other components) which you can use > to implement an open/saveas dialog. there is one example of an open/saveas dialog component posted on the ccrp website. If "ccrp" doesn't bring forth any blinding flashes of recognition, it stands for "Common Controls Replacement Project", and they were a bunch of guys (sorry, no gals) who were so arrogant that they thought that they could do a better job programming the common controls than microsoft (gasp!). Any I my humble opinion they succeeded. (So did Steve McMahon, but that's another subject). The ccrp labored for years to produce "better controls", but eventually gave up the ghost when vb.net came out. However, their website was preserved under the auspices of "mvps.org", (the "most valuable programming persons" organization -- set up by microsoft to get people to answer questions that microsoft itself didn't want to bother with). Anyway, ccrp came up with enhanced versions of the open/saveas dialog(s), published as an actX oject, which may be found here: http://ccrp.mvps.org/index.html?cont...rpfiledlg6.htm cheers, jw |
My System Specs![]() |
| | #4 (permalink) |
| | Re: yet another open/saveas dialog possibility mr_unreliable wrote: Quote: > There are other ways (and other components) which you can use > to implement an open/saveas dialog. Peter J.C. van der Klugt has offered up a general purpose wsh/vbs graphical interface (gui) package, called wshDialog. If interested, you can find it here: http://home.hccnet.nl/p.vd.klugt/ It provides the same sort of windows interface you would get using vb "forms", but in addition it will also allow you to show the usual "common dialogs" including open and saveas. Here is a script, showing how to get an open file dialog, as adapted from an example in P.V.D.Klugt's help file: --- <code> --- ' create the wshDialog.Kit object and store a reference in oDlg Dim oDlg : Set oDlg = Wscript.CreateObject("WshDialog.Kit", "oDlg_") ' get a reference to the common dialog class (object) Dim oCommDlg : Set oCommDlg = oDlg.CommonDialog ' open file flag constants (see help file for others) Const OFNAllowMultiselect = &H200 With oCommDlg .DialogTitle = "Select a file to open..." .MaxFileSize = 512 ' allocate sufficient space for filespec(s) .CancelError = True ' attempting to cancel will throw error .InitDir = "C:\" .Filter = "Text (*.txt)|*.txt|Pictures (*.bmp;*.ico)|*.bmp;*.ico" ' .Flags = OFNAllowMultiselect ' skip this for now .ShowOpen ' show the dialog End With Dim iFile ' as long ' read the selected file(s) from the FileName property ' (depending on your OS, the delimiter maybe either nulls or spaces!) Dim saFiles : saFiles = Split(oCommDlg.FileName, Chr(0)) ' string array Select Case Ubound(saFiles) Case -1 MsgBox "No file(s) selected" Case 0 ' only 1 file selected MsgBox "Filespec: " & saFiles(0), vbOK, "File (1) You Opened" Case Else For iFile = 1 To Ubound(saFiles) ' note: the directory is at index 0, ' all others elements are the selected files MsgBox saFiles(0) & "\" & saFiles(iFile), vbOK, _ "File (" & CStr(iFile) & ") You Opened" Next ' iFile End Select MsgBox("Script Closing Now.. ") WScript.Quit --- </code> --- cheers, jw |
My System Specs![]() |
| | #5 (permalink) |
| | Re: VBScript, HTA and CommonDialog in PE As mr_unreliable said, that control must be licensed. It comes with Visual Studio 6. I doubt that it's part of later .Net releases since it's an ActiveX control. Comdlg32.ocx is actually the control, which wraps Comdlg32.dll. You can use the latter without a license but script can't make the API calls necessary. See here for a method that might work on XP: http://www.microsoft.com/technet/scr.../fileopen.mspx I don't know about how it relates to Vista/PE. Also, &H80000 AND &H2 = 0 If you want to add flags use Or. Flags = &H80002 Flags = &H80000 Or &H2 Quote: > I'm working on a project in WinPE and am using an HTA with vbscript in > it. Everything works great in WinPE, except a call to > MSComDlg.CommonDialog for saving and opening files. These calls work > in Vista x86 Business, but I can't get them to work in PE. I've > brought over and registered both the Comdlg32.ocx and Comdlg32.dll, I > still get the notice about ActiveX component can't create object for > the MScomdlg. I have the scripting, hta, and xml packages installed on > the PE image. Any help in this matter would be appreciated. The code > in question is as follows: > > <script for="begin" event="OnClick" language="vbscript"> > file://dim capdep, syst, fileLoc > If StrComp(document.getElementByID("protype").value,"") = 0 Then > MsgBox "Error: No action Chosen" > ElseIf StrComp(document.getElementByID("promodel").value,"") = 0 > Then > MsgBox "Error: Choose a Model" > Else > Set objDialog = CreateObject("MSComDlg.CommonDialog") > objDialog.MaxFileSize = 260 > objDialog.InitDir = "z:\" & > document.getElementByID("promodel").value > objDialog.Filter = "Image Files|*.wim" > objDialog.Flags = &H80000 AND &H2 > objDialog.FilterIndex = 1 > If StrComp(document.getElementByID("protype").value,"Capture") = > 0 Then > objDialog.ShowSave > capdep = "cap" > Else > objDialog.Flags = objDialog.Flags AND &H1000 > objDialog.ShowOpen > capdep = "dep" > End If > Etc.. > > > > I don't know what i'm missing to get the MSComDlg to work in WinPE |
My System Specs![]() |
| | #6 (permalink) |
| | Re: VBScript, HTA and CommonDialog in PE Thank you all for your replies. I will check out the resources and options you sent me do and report back when i find something that works well in the bunch. |
My System Specs![]() |
| | #7 (permalink) |
| | Re: VBScript, HTA and CommonDialog in PE I've continued to have no success getting any of the above to work properly. Thanks for all that helped, but I've decided to make my own method using html/vbscript. On Sep 29, 8:44*am, hbasse...@xxxxxx wrote: Quote: > Thank you all for your replies. I will check out the resources and > options you sent me do and report back when i find something that > works well in the bunch. |
My System Specs![]() |
| | #8 (permalink) |
| | Re: VBScript, HTA and CommonDialog in PE Here's a simple version that should work on all Windows versions, in case you need it. But you'll lose the options like initial folder path, extension filter, etc. that you would have had with the comdlg version. '------------------------ Function Browse() On Error Resume Next Dim Q2, sRet Q2 = Chr(34) Browse = "" Set IE = CreateObject("InternetExplorer.Application") IE.visible = False IE.Navigate("about:blank") Do Until IE.ReadyState = 4 Loop IE.Document.Write "<HTML><BODY><INPUT ID=" & Q2 & "Fil" & Q2 & "Type=" & Q2 & "file" & Q2 & "></BODY></HTML>" With IE.Document.all.Fil .focus .click sRet = .value End With IE.Quit Set IE = Nothing If (FSO.FileExists(sRet) = True) Then Browse = sRet End Function '-------------------- Quote: > properly. Thanks for all that helped, but I've decided to make my own method using html/vbscript. On Sep 29, 8:44 am, hbasse...@xxxxxx wrote: Quote: > Thank you all for your replies. I will check out the resources and > options you sent me do and report back when i find something that > works well in the bunch. |
My System Specs![]() |
| | #9 (permalink) |
| | Re: VBScript, HTA and CommonDialog in PE I came into this problem while developing my products @ www.xneat.com so i called win32 API instead If this is ok for your project you can converter your HTA into exe and from within it you can call win32 API Below is how i call the show dialog from within xNeat Application Builder http://www.xneat.com/application-builder/ this.GetFile2 = function(ExtText,ExtFilter,IsOpenDlg) { var OpenFile = XNHost.Struct; OpenFile.add("lStructSize","ui32"); OpenFile.add("hwndOwner","ui32"); OpenFile.add("hInstance","ui32"); OpenFile.add("lpstrFilter","ui32"); OpenFile.add("lpstrCustomFilter","ui32"); OpenFile.add("nMaxCustFilter","ui32"); OpenFile.add("nFilterIndex","ui32"); OpenFile.add("lpstrFile","ui32"); OpenFile.add("nMaxFile","ui32"); OpenFile.add("lpstrFileTitle","ui32"); OpenFile.add("nMaxFileTitle","ui32"); OpenFile.add("lpstrInitialDir","ui32"); OpenFile.add("lpstrTitle","ui32"); OpenFile.add("Flags","ui32"); OpenFile.add("nFileOffset","ui16"); OpenFile.add("nFileExtension","ui16"); OpenFile.add("lpstrDefExt","ui32"); OpenFile.add("lCustData","ui32"); OpenFile.add("lpfnHook","ui32"); OpenFile.add("lpTemplateName","ui32"); var sFilter = XNHost.Struct; sFilter.Add("buf1","w",ExtText.length); sFilter.Add("x","ui16"); sFilter.Add("buf2","w",ExtFilter.length); sFilter.Add("y","ui32"); sFilter.buf1 = ExtText; sFilter.buf2 = ExtFilter; var sFilePath = XNHost.Struct; sFilePath.Add("buffer","w",1024); var sInitialDir = XNHost.Struct; sInitialDir.Add("buffer","w", this.getCurrentDir().length+1 ); sInitialDir.buffer = this.getCurrentDir(); // var sTitle = XNHost.Struct; // sTitle.Add("buffer","w",1024); // sTitle.buffer = "Use the Comdlg API not the OCX"; OpenFile.lStructSize = 19*4; OpenFile.hwndOwner = XNHost.window; OpenFile.hInstance = XNHost.call("kernel32.dll","GetModuleHandle",0); OpenFile.lpstrFilter = sFilter.ptr; OpenFile.nFilterIndex = 1; OpenFile.lpstrFile = sFilePath.ptr; OpenFile.nMaxFile = 1023; OpenFile.lpstrInitialDir = sInitialDir.ptr; // OpenFile.lpstrTitle = sTitle.ptr; OpenFile.Flags = 0; var result; if(IsOpenDlg == true) { result = XNHost.call("comdlg32.dll","GetOpenFileNameW",OpenFile.ptr); } else { result = XNHost.call("comdlg32.dll","GetSaveFileNameW",OpenFile.ptr); } if( result == 0 ) { return 0; } else { return sFilePath.buffer; } } <hbasselet@xxxxxx> wrote in message news:8f77b2c3-c173-4fa8-9caf-3b73df6e1b23@xxxxxx Quote: > I'm working on a project in WinPE and am using an HTA with vbscript in > it. Everything works great in WinPE, except a call to > MSComDlg.CommonDialog for saving and opening files. These calls work > in Vista x86 Business, but I can't get them to work in PE. I've > brought over and registered both the Comdlg32.ocx and Comdlg32.dll, I > still get the notice about ActiveX component can't create object for > the MScomdlg. I have the scripting, hta, and xml packages installed on > the PE image. Any help in this matter would be appreciated. The code > in question is as follows: > > <script for="begin" event="OnClick" language="vbscript"> > //dim capdep, syst, fileLoc > If StrComp(document.getElementByID("protype").value,"") = 0 Then > MsgBox "Error: No action Chosen" > ElseIf StrComp(document.getElementByID("promodel").value,"") = 0 > Then > MsgBox "Error: Choose a Model" > Else > Set objDialog = CreateObject("MSComDlg.CommonDialog") > objDialog.MaxFileSize = 260 > objDialog.InitDir = "z:\" & > document.getElementByID("promodel").value > objDialog.Filter = "Image Files|*.wim" > objDialog.Flags = &H80000 AND &H2 > objDialog.FilterIndex = 1 > If StrComp(document.getElementByID("protype").value,"Capture") = > 0 Then > objDialog.ShowSave > capdep = "cap" > Else > objDialog.Flags = objDialog.Flags AND &H1000 > objDialog.ShowOpen > capdep = "dep" > End If > Etc.. > > > > I don't know what i'm missing to get the MSComDlg to work in WinPE |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| New to VBscript, Help please! | VB Script | |||
| CSS and VBscript | VB Script | |||
| How to do No hang up VBScript (nohup for VBScript) | VB Script | |||
| vbscript and HTA help | VB Script | |||
| CommonDialog | Vista installation & setup | |||