2009-07-28 63 views

回答

2

你有两个选择这样做:您可以覆盖内置FileSaveFileSaveAs命令,也可以为应用程序创建的DocumentBeforeSave事件的事件处理程序(这是一个小更多的工作要做)。

重写的内置命令可以通过添加以下代码以一个VBA模块来实现(调整到相应显示在用户表格的类型):

' override File -> Save 
Public Sub FileSave() 

    CustomSave 
    ' call ActiveDocument.Save to actually save the document 

End Sub 

' override File -> Save As... 
Public Sub FileSaveAs() 

    CustomSave 
    ' call ActiveDocument.SaveAs to actually save the document 

End Sub 

Sub CustomSave() 

    Dim frm As New frmCustomSave 
    frm.Show 

End Sub 

第二个选项可以通过实施下配售Microsoft Word中下面的代码对象 - >的ThisDocument在VBA编辑:

Option Explicit 

Private WithEvents wdApp As Word.Application 

Private Sub Document_New() 
    Set wdApp = Word.Application 
End Sub 

Private Sub Document_Open() 
    Set wdApp = Word.Application 
End Sub 

Private Sub wdApp_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean) 

    Dim frm As New frmCustomSave 
    frm.Show 

End Sub