保存Word文档和DisplayAlerts

我试图使用Application.DisplayAlerts = wdAlertsNoneApplication.DisplayAlerts = False在我的剧本,以避免到有字弹出消息“被保存的文档包含轨道变化继续保存吗?”只字VBA脚本之前保存一个word文档。但它不起作用。该消息仍然存在。保存Word文档和DisplayAlerts

这里我的脚本:

Private Sub CreateReportButton_Click() 

Dim objDocA As Word.Document

Dim objDocB As Word.Document

Dim objDocC As Word.Document

Dim objFSO As Scripting.FileSystemObject

Dim objFolderA As Scripting.Folder

Dim objFolderB As Scripting.Folder

Dim objFolderC As Scripting.Folder

Dim colFilesA As Scripting.Files

Dim objFileA As Scripting.File

Dim i As Integer

Dim j As Integer

Set objFSO = New FileSystemObject

Set objFolderA = objFSO.GetFolder(ChooseFolder("Choose the folder with the original documents", ThisDocument.Path))

Set objFolderB = objFSO.GetFolder(ChooseFolder("Choose the folder with revised documents", ThisDocument.Path))

Set objFolderC = objFSO.GetFolder(ChooseFolder("Choose the folder for the comparisons documents", ThisDocument.Path))

Set colFilesA = objFolderA.Files

For Each objFileA In colFilesA

If objFileA.Name Like "*.docx" Then

Set objDocA = Documents.Open(objFolderA.Path & "\" & objFileA.Name)

Set objDocB = Documents.Open(objFolderB.Path & "\" & objFileA.Name)

Set objDocC = Application.CompareDocuments(_

OriginalDocument:=objDocA, _

RevisedDocument:=objDocB, _

Destination:=wdCompareDestinationNew)

objDocA.Close

objDocB.Close

On Error Resume Next

Kill objFolderC.Path & "\" & objFileA.Name

On Error GoTo 0

'Turn off DisplayAlerts

Application.DisplayAlerts = wdAlertsNone

objDocC.SaveAs FileName:=objFolderC.Path & "\" & objFileA.Name

objDocC.Close SaveChanges:=False

End If

Next objFileA

End Sub

能否请你帮我解决这个问题?

预先感谢您的帮助

回答:

显然,这取决于办公室的版本,2013年有必要去应用程序的信任中心区(文件>选项>信任中心>信任中心设置>隐私选项),并取消选中“打印前保存,保存或发送包含已跟踪更改或评论的文件”选项。这样做后,文件保存任何消息的Word

以上是 保存Word文档和DisplayAlerts 的全部内容, 来源链接: utcz.com/qa/262545.html

回到顶部