tags:

views:

1112

answers:

3

I'm developing an html editor using ComDlg32.ocx (Commom Dialog Control), using HTML and VBScript. My exact requirement was to prompt Open/Save/Color/Print/Font dialog boxes.Ive written code for prompting Save file dialog box. Also I've added a license file using LPK Tool onto my webpage.

My html-source looks like:

<body>
<!-- lpk file -->
<object classid="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
   <param name="LPKPath" value="License/comdlg.lpk" />
</object>
<!-- Microsoft Common Dialog Control -->
<object classid="CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB" codebase="http://activex.microsoft.com/controls/vb6/COMDLG32.CAB" id="objComDlg"></object>
</body>

Now, here comes my error. Whenever I try to call the vbscript for prompting the Save File dialog box, Im getting an error as : Object doesn't support this property or method: 'objComDlg.Filter'

If I comment out the objComDlg.Filter then the error move on to objComDlg.DialogTitle and thus it goes on.

And my VBScript look like:

FILE_FORMATS = "Rich Text Format (*.rtf)|*.rtf|Microsoft Word (*.doc)|*.doc|ANSI Text Document (*.txt)|*.txt"
objComDlg.Filter = FILE_FORMATS <--- Error shows here
objComDlg.DialogTitle = "Save As "
objComDlg.Flags = cdlOFNFileMustExist Or cdlOFNHideReadOnly
objComDlg.CancelError = True
objComDlg.ShowSave

Does anyone have an idea why this is happening? Is there any proper documentation for using this particular ActiveX control? My current development is in stand-still due to this error.

Any help will be appreciated. Looking forward for your response.

BTW, I'm using Windows XP SP3 and IE8 for my development.

Thanks.

A: 

Do you create your objComDlg above the VBscript you posted? Something like:

Dim objComDlg As Object : Set objComDlg = CreateObject("MSComDlg.CommonDialog")
hyperslug
I slightly modified the code above.Dim objComDlgSet objComDlg = CreateObject("MSComDlg.CommonDialog") <- Error comes hereUpon running the page.I'm recieving an error as "The control could not be created because it is not properly licensed."Is that due to the problem with .lpk file that I've created. Please suggest.
abhilashca
+1  A: 

It sounds like your problem may be related to some major changes MS made to OCX libraries to fix various security holes in the controls. I notice you are running SP3, this probably included the fixes, which appear to have had knock-on effects on the controls, e.g. some methods have disappeared!

I ran into the same problem - a method was being called in a legacy app on msflxgrd.ocs (Rows method) which did not seem to exist. Took me friggin ages to find the solution. My guess is you either need to roll back the security update, or change your code to not use that missing objComDlg.Filter method.

See this article for more info.

-- EDIT

OK I have some more specific info now, this worked for me (except my problem was with msflxgrd.ocx, but I think it's the same issue).

There is a specific microsoft update (KB960715) which has plugged some holes in ActiveX controls, so the vulnerable methods are still there in the controls but are blocked by killbits. Removing the update has solved my problem, obviously if you can it would be better to change your code, because removing the update makes you vulnerable to exploits it was designed to fix!

James Allen
Hi,Thanks for the reply.I've escalated the same problem in MSDN and Technet forums. But, I didnt get any postive response either. And no one mentioned the trouble with Win XP SP3. I wonder why they're not able to provide any solution.Huh!Thanks.
abhilashca
Ive updated my answer with more info, try uninstalling KB960715 and see what happens
James Allen
+1  A: 

Hi,

I have been experiencing exactly the same problem, but it only occurs on certain machines. I managed to recreate the problem with the following steps:

  1. Using Microsoft Virtual PC 2007, install a clean build of XP Pro.
  2. Without installing anything else, other than the VM Addons, apply all of the MS Updates.
  3. Run the code as described above. I have provided an alternative below too.

It would seem that the problem has occurred through an MS update. Using the KB240797 knowledge base article (http://support.microsoft.com/default.aspx/kb/240797?p=1), I was able to determine that a kill bit had been issued for the Common Dialog ActiveX control, and an alternative class ID provided (8F0F480A-4366-4737-8265-2AD6FDAC8C31), suggesting that the control had been superseded. However, after checking other machines on which the control worked, specifically development machines (XP Pro x64, XP Pro x32 & Vista x32), each with a copy of Visual Studio 2008 installed, there was no kill bit entry nor was there an alternative class ID.

To get the dialog working, I simply renamed the registry key (I could have deleted it as well), meaning that there was no longer a kill bit. Hey presto, it worked!

The registry key is:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility{F9043C85-F6F2-101A-A3C9-08002B2F49FB}

I guess that there is a chance that this will be re-applied with a future Microsoft cumulative update, and it may also open up some security vulnerability.

I hope that that helps you. Thanks for your original post as it seems to have set me on the right track.

Kaine

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
    <title>Common Dialog Test</title>


    <script language="vbscript" type="text/vbscript">
    Sub AlertErr()
      On Error Resume Next

      document.objComDlg.Copies = 1
      document.objComDlg.FromPage = 1
      document.objComDlg.ToPage = 1
      document.objComDlg.Min = 1
      document.objComDlg.Max = 1
      document.objComDlg.Flags = cdlPDHidePrintToFile Or cdlPDNoSelection
      document.objComDlg.CancelError = True

      printerDialog = document.objComDlg.ShowPrinter
      If Err.Number = 0 Then
        Call MsgBox("No Error. The print simulation worked as expected.")
      ElseIf Err.Number = 32755 Then
        Call MsgBox("You clicked the 'Cancel' button.")
      Else
        Call MsgBox("The following error occurred: " & Err.Description & " (" & Err.Number & ")")
      End If
    End Sub
    </script>
</head>
<body>
    <div>
      <button id="btnAlertErr" onclick="AlertErr()">Print Me</button>

        <object classid="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
            <param name="LPKPath" value="CommonDialog.lpk">
        </object>

        <object id="objComDlg" codebase="http://activex.microsoft.com/controls/vb6/comdlg32.cab" classid="clsid:F9043C85-F6F2-101A-A3C9-08002B2F49FB" viewastext>
          <param name="_ExtentX" value="847" />
          <param name="_ExtentY" value="847" />
          <param name="_Version" value="393216" />
          <param name="_Version" value="393216" />
          <param name="CancelError" value="0" />
          <param name="Color" value="0" />
          <param name="Copies" value="1" />
          <param name="DefaultExt" value="" />
          <param name="DialogTitle" value="" />
          <param name="FileName" value="" />
          <param name="Filter" value="" />
          <param name="FilterIndex" value="0" />
          <param name="Flags" value="0" />
          <param name="FontBold" value="0" />
          <param name="FontItalic" value="0" />
          <param name="FontName" value="" />
          <param name="FontSize" value="8" />
          <param name="FontStrikeThru" value="0" />
          <param name="FontUnderLine" value="0" />
          <param name="FromPage" value="0" />
          <param name="HelpCommand" value="0" />
          <param name="HelpContext" value="0" />
          <param name="HelpFile" value="" />
          <param name="HelpKey" value="" />
          <param name="InitDir" value="" />
          <param name="Max" value="0" />
          <param name="Min" value="0" />
          <param name="MaxFileSize" value="260" />
          <param name="PrinterDefault" value="1" />
          <param name="ToPage" value="0" />
          <param name="Orientation" value="1" />
      </object>
    </div>
</body>
</html>
Kaine Varley