在代码中进行自动化时可以抑制 Visio 的宏警告提示吗?

发布于 2024-07-25 04:59:00 字数 945 浏览 4 评论 0原文

我正在从 VB.NET 应用程序自动化 Visio 2003。 我的代码看起来像这样(删除了无趣的东西):

Dim objApp As New Microsoft.Office.Interop.Visio.InvisibleApp
objApp.Settings.ShowFileOpenWarnings = False
Dim objDoc As Microsoft.Office.Interop.Visio.Document
objDoc = objApp.Documents.Open(VisioFilename)

我发现最后一行导致 Visio 引发一个隐藏的 MessageBox 说:

此文档中的宏被禁用,因为安全级别很高,并且宏尚未被数字化签名或验证为安全。 要运行宏,您可以对其进行签名或更改安全级别。

由于这将在我无法控制的计算机上运行,​​所以我无法控制这些选项对我来说都不适用。 我真的不在乎宏是否被禁用,我只是使用 Visio 将文件从其本机格式转换为 SVG。 我当然不想建议用户降低安全级别,我也不想为他们降低安全级别。

正如您从上面的代码中看到的,我关闭了文件打开警告,但这似乎不包括宏警告。 由于我使用的是 Visio.InvisibleApp,结果警告不会向用户显示。 运行 Visio 的可见实例不会有帮助,因为我正在创建批处理转换器,即使消息可见,也意味着用户必须为每个文件单击“确定”。 这将使批量转换功能基本上毫无用处。

我看到 Visio 类具有 VBAEnabled 属性,但它是只读的。 如果有一种方法可以在打开文件时关闭 VBA,则可能会解决问题。 我已经查看了类的所有属性和“设置”属性,但找不到任何内容。 我已经进行了大量的谷歌搜索,但找不到任何可以解决这个问题的内容。

有人知道在 Visio 中使用自动化时是否可以抑制该警告吗? 如果我切换到 Visio 2007 可以吗?

I'm automating Visio 2003 from a VB.NET app. My code looks like this (with the uninteresting stuff removed):

Dim objApp As New Microsoft.Office.Interop.Visio.InvisibleApp
objApp.Settings.ShowFileOpenWarnings = False
Dim objDoc As Microsoft.Office.Interop.Visio.Document
objDoc = objApp.Documents.Open(VisioFilename)

I've found that the last line causes Visio to raise a hidden MessageBox saying:

Macros in this document are disabled because the security level is high, and the macros have not been digitally signed or verified as safe. To run the macros, you can either have them signed or change your security level.

Since this is going to be running on computers I don't control with files I don't control neither of those options works for me. I really don't care that the macros are disabled, I'm just using Visio to convert the file from it's native format to SVG. I certainly don't want to suggest to users that they lower the security level, nor would I want to lower it for them.

As you can see from my code above, I turn off file open warnings but that doesn't seem to include the macro warning. Since I'm using Visio.InvisibleApp it turns out the warning isn't displayed to the user. Running a visible instance of Visio won't help because I'm creating a batch converter, even if the message was visible it means the user would have to click OK for each file. That would make the batch conversion feature essentially useless.

I see that the Visio class has a VBAEnabled property but it's read only. If there was a way I could just turn off VBA when opening the file it would likely solve the problem. I've looked all through the properties and through the Settings property on the class and can't find anything. I've done a bunch of Google searching and can't find anything that addresses this issue.

Anyone know if that warning can be suppressed when using automation with Visio? Can I do it if I switch to Visio 2007?

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

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

发布评论

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

评论(1

埖埖迣鎅 2024-08-01 04:59:00

有一个 OpenEx 方法,其工作方式与 Open 类似,但它接受标志。 这些标志之一是 visOpenMacrosDisabled (&H80)。

那里还有一些其他方便的标志,例如 visOpenDontList (&H8),因此通过自动化打开的文件不会添加到最近的文件列表中。

There is an OpenEx method that works just like Open but it accepts flags. One of those flags is visOpenMacrosDisabled (&H80).

There are also some other handy flags in there like visOpenDontList (&H8) so the files opened through automation won't be added to the recent files list.

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