关闭文档时宏运行的问题 [英] Problem with Macro Running When Closing a Document

查看:106
本文介绍了关闭文档时宏运行的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计;


我正在尝试开发一个在关闭文档时运行的Visio宏,但我遇到了麻烦...


问题是以下代码仅在我按下文档一角的"X"关闭时才有效。 如果我尝试使用
文件 - >关闭它关闭,我收到错误"运行时错误-2032464741(86db0c9b)发生异常",调试器突出显示第一个"应用程序"行。


我需要无论关闭操作如何,代码都可以工作,我不知道如何实现这一点(因为我认为无论如何都应该工作相同)。

私有函数Document_QueryCancelDocumentClose(ByVal doc As IVDocument)As Boolean 
Document_QueryCancelDocumentClose = True
如果MsgBox("如果进行了更改,是否更新了图表历史记录?"(如果未进行任何更改,请选择"是") )",vbYesNo + vbCritical + vbDefaultButton2," Warning-DIAGRAM HISTORY UPDATED?")= vbYes Then
Application.ActiveDocument.Pages.ItemU(" Diagram")。Layers.Item(" Warning" ).CellsC(4)= 1
Document_QueryCancelDocumentClose = False
Else
Document_QueryCancelDocumentClose = True
End if
结束功能

任何帮助都将不胜感激。


Zang

解决方案


当您通过文件关闭文件时 - >关闭,然后在那时,代码无法获得" ItemU "图" <跨度>)"因为它无法获取哪个页面和哪个项目。


尝试更改诸如Pages(1).Item(1)......之类的代码来检查问题。


Hi Folks;

I'm trying to develop a Visio macro that runs when I close a document, but I've run into a snag...

The problem is that the code below only works when I press the 'X' in the corner of the document to close it.  If I try to close it using File -> Close, I get the error "Run Time Error -2032464741 (86db0c9b) An exception occurred", and the debugger highlights the first 'Application' line.

I need the code to work regardless of the close operation, and I'm not sure how to make that happen (since I assumed it should've work the same regardless).

Private Function Document_QueryCancelDocumentClose(ByVal doc As IVDocument) As Boolean
Document_QueryCancelDocumentClose = True
    If MsgBox("If you made changes, did you UPDATE the Diagram History? (Select Yes if no changes were made)", vbYesNo + vbCritical + vbDefaultButton2, "Warning - DIAGRAM HISTORY UPDATED?") = vbYes Then
        Application.ActiveDocument.Pages.ItemU("Diagram").Layers.Item("Warning").CellsC(4) = 1
        Document_QueryCancelDocumentClose = False
    Else
        Document_QueryCancelDocumentClose = True
    End If
End Function

Any help would be appreciated.

Zang

解决方案

Hi,

When you close the file via File -> Close, then at that time, the code cannot get "Pages.ItemU("Diagram")" because it cannot get which page and which item.

Try to change the code such as Pages(1).Item(1)......to check the issue.


这篇关于关闭文档时宏运行的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆