Word VBA - 自动恢复调用DocumentBeforeSave事件

时间:2015-01-28 04:38:56

标签: vba ms-word word-vba

在Word VBA中,我有一个名为Events的调用,其中包含以下代码:

Public WithEvents EventSource As Word.Application

Private Sub EventSource_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
If oScript.DocType = diDocTypeScript Then

    WriteToTextLog " SaveAsUI = " & CStr(SaveAsUI) & "Path= " & Doc.Path & " Name= " & Doc.Name
    If SaveAsUI Then
        Call Me.SaveAsBox(Doc)
    Else
        oScript.DlgTimeLastSaved = Now()
        Doc.Save
        If oDlgApplication.DevelopMode Then MsgBox "Saving Document: " & Doc.FullName
    End If

    Cancel = True
End If
End Sub

现在的问题是,当自动恢复触发时,会自动调用此保存方法并保存实际文件,而不是保存文件的备份版本,以防Word崩溃。

那么有没有办法识别自动保存(恢复)并保持原样?

谢谢, 特加斯

0 个答案:

没有答案