Vba ActiveX控件阻止我。已保存=True
以前我用过这个:Vba ActiveX控件阻止我。已保存=True,vba,ms-word,activexobject,Vba,Ms Word,Activexobject,以前我用过这个: Private Sub Document_Close() Me.Saved = True End Sub 为了在退出Word文档并进行更改时禁用保存提示,我添加了一个“组合框(ActiveX控件)”,现在Word再次提示保存。有办法解决这个问题吗 我试着编写代码,在文档关闭时删除组合框,但框在使用后会自动删除(不是我的代码,它只是这样),然后当文档关闭时,框不存在,并在那里导致错误。我可以做一个if-exist/错误控制,但我觉得这只是变得草率,而不是找到根本问题。。
Private Sub Document_Close()
Me.Saved = True
End Sub
为了在退出Word文档并进行更改时禁用保存提示,我添加了一个“组合框(ActiveX控件)”,现在Word再次提示保存。有办法解决这个问题吗
我试着编写代码,在文档关闭时删除组合框,但框在使用后会自动删除(不是我的代码,它只是这样),然后当文档关闭时,框不存在,并在那里导致错误。我可以做一个if-exist/错误控制,但我觉得这只是变得草率,而不是找到根本问题。。。有人能帮忙吗?如果有同样的问题,并通过Bing找到了解决方案: 以下代码帮助我解决了这个问题:
Dim WithEvents App As Application
Private Sub App_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
'Did the user saved our file?
If Not ThisDocument.Saved Then
'Close our file?
If Doc.Name = ThisDocument.Name Then
'Cancel the dialog always!
Cancel = True
'Set the save state
ThisDocument.Saved = True
'Close the document after this event
Application.OnTime Now + TimeSerial(0, 0, 1), Me.CodeName & ".Document_AfterClose"
End If
End If
End Sub
Sub Document_AfterClose()
'Close the document without saving
ThisDocument.Close False
End Sub
Private Sub cboEquip_Change()
'Let the document know that a change is made
ThisDocument.Saved = False
End Sub
Private Sub Document_Open()
Set App = Application
End Sub
如果有相同的问题,并通过Bing找到了解决方案: 以下代码帮助我解决了这个问题:
Dim WithEvents App As Application
Private Sub App_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
'Did the user saved our file?
If Not ThisDocument.Saved Then
'Close our file?
If Doc.Name = ThisDocument.Name Then
'Cancel the dialog always!
Cancel = True
'Set the save state
ThisDocument.Saved = True
'Close the document after this event
Application.OnTime Now + TimeSerial(0, 0, 1), Me.CodeName & ".Document_AfterClose"
End If
End If
End Sub
Sub Document_AfterClose()
'Close the document without saving
ThisDocument.Close False
End Sub
Private Sub cboEquip_Change()
'Let the document know that a change is made
ThisDocument.Saved = False
End Sub
Private Sub Document_Open()
Set App = Application
End Sub
那么Application.DisplayAlerts=wdAlertsOne ActiveDocument.Close SaveChanges:=False呢?@DanielDusek我刚刚在
Private Sub Document\u Open()
中尝试了Application.DisplayAlerts=wdAlertsOne
,在Private Sub Document\u Close()中分别尝试了ActiveDocument.Close SaveChanges:=False
)
两种方法都不起作用。我把它们放错地方了吗?我有ActiveDocument.Close SaveChanges:=False
在用户单击按钮时使用(在执行其他过程后),但如果有人意外打开文档或不想使用它,请使用右上角[X]将其关闭按钮仍然会弹出提示。那么Application.DisplayAlerts=wdAlertsOne ActiveDocument呢。关闭SaveChanges:=False?@DanielDusek我刚刚在私有子文档中尝试了Application.DisplayAlerts=wdAlertsOne
,并分别在私有子文档中ActiveDocument.Close SaveChanges:=False
\u Close()
,两者都不起作用。我把它们放错地方了吗?我有ActiveDocument.Close SaveChanges:=False
在用户单击按钮时使用(在执行其他过程后),但是如果有人意外打开文档或不想使用它,使用右上角的[X]按钮关闭文档仍会显示提示。感谢您的响应!但是,如果您查看发布该问题的用户…:P在这里有一些观点,但没有答案,所以我去了微软论坛。谢谢你的回复,非常感谢你的帮助!哈哈,没有注意到这是你在微软论坛上的问题。谢谢你的回复!但是,如果您查看发布该问题的用户…:P在这里有一些观点,但没有答案,所以我去了微软论坛。谢谢你的回复,非常感谢你的帮助!哈哈,没注意到这是你在微软论坛上的问题。