ComDlg32.ocx 错误:对象不支持此属性或方法

发布于 2024-07-27 19:03:15 字数 1337 浏览 10 评论 0原文

我正在使用 ComDlg32.ocx(通用对话框控件)、HTML 和VBScript 开发一个 html 编辑器。 我的具体要求是提示打开/保存/颜色/打印/字体对话框。我已经编写了提示保存文件对话框的代码。 此外,我还使用 LPK Tool 在我的网页上添加了一个许可证文件。

我的 html 源代码看起来像:

<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>

现在,我的错误来了。 每当我尝试调用 vbscript 来提示“保存文件”对话框时,都会收到以下错误: 对象不支持此属性或方法:“objComDlg.Filter”

如果我注释掉objComDlg.Filter,则错误将转移到objComDlg.DialogTitle< /em> 就这样继续下去。

我的 VBScript 看起来像:

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

有谁知道为什么会发生这种情况吗? 是否有任何使用此特定 ActiveX 控件的适当文档? 由于这个错误,我目前的开发处于停滞状态。

顺便说一句,我使用 Windows XP SP3 和 IE8 进行开发。

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, I'm 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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦忆晨望 2024-08-03 19:03:15

听起来您的问题可能与 MS 对 OCX 库进行的一些重大更改有关,以修复控件中的各种安全漏洞。 我注意到您正在运行 SP3,这可能包括修复程序,这些修复程序似乎对控件产生了连锁反应,例如某些方法消失了!

我遇到了同样的问题 - 在 msflxgrd.ocs(行方法)上的旧应用程序中调用了一个方法,该方法似乎不存在。 我花了很长时间才找到解决方案。 我的猜测是您要么需要回滚安全更新,要么更改代码以不使用缺少的 objComDlg.Filter 方法。

有关详细信息,请参阅本文

-- 编辑

好的,我现在有一些更具体的信息,这对我有用(除了我的问题是 msflxgrd.ocx,但我认为这是同一个问题)。

有一个特定的 Microsoft 更新 (KB960715) 修复了一些漏洞在 ActiveX 控件中,因此易受攻击的方法仍然存在于控件中,但被 Killbit 阻止。 删除更新已经解决了我的问题,显然,如果可以的话,最好更改代码,因为删除更新会使您容易受到旨在修复的漏洞的攻击!

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!

十级心震 2024-08-03 19:03:15

我也遇到过完全相同的问题,但它只发生在某些机器上。 我设法通过以下步骤重现该问题:

  1. 使用 Microsoft Virtual PC 2007,安装 XP Pro 的全新版本。
  2. 除 VM 插件外,无需安装任何其他内容,即可应用所有 MS 更新。
  3. 按上述方式运行代码。 我也在下面提供了一个替代方案。

该问题似乎是通过 MS 更新发生的。 使用 KB240797 知识库文章 (http://support.microsoft.com /default.aspx/kb/240797?p=1),我能够确定已为公共对话框 ActiveX 控件发出了终止位,并提供了替代类 ID (8F0F480A-4366-4737- 8265-2AD6FDAC8C31),表明对照已被取代。 然而,在检查了该控件运行的其他机器后,特别是开发机器(XP Pro x64、XP Pro x32 和 Vista x32),每台机器都安装了 Visual Studio 2008 的副本,没有kill bit条目,也没有替代方案班级号。

为了使对话框正常工作,我只是重命名了注册表项(我也可以将其删除),这意味着不再有终止位。 嘿,很快,它成功了!

注册表项是:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet
资源管理器\ActiveX
兼容性{F9043C85-F6F2-101A-A3C9-08002B2F49FB}

我猜想这有可能会在未来的微软累积更新中重新应用,并且还可能会带来一些安全漏洞。

我希望这对你有帮助。 感谢您的原始帖子,因为它似乎让我走上了正确的道路。

凯恩

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

<html xmlns="http://www.w3.org/1999/xhtml">
<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>

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">

<html xmlns="http://www.w3.org/1999/xhtml">
<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>
瑶笙 2024-08-03 19:03:15

您是否在您发布的 VBscript 之上创建 objComDlg? 就像是:

Dim objComDlg As Object : Set objComDlg = CreateObject("MSComDlg.CommonDialog")

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

Dim objComDlg As Object : Set objComDlg = CreateObject("MSComDlg.CommonDialog")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文