如何使用宏关闭跟踪的更改?

时间:2019-04-11 14:33:01

标签: vba ms-word

我一直试图创建一个宏,当我打开一个新的Word文档时该宏将自动运行,该文档将验证是否已关闭跟踪的更改。出于某种原因,每当我运行一个宏以打开一个新的Word文档(该文档是一个包含表单的.dotm文件)时,它都会打开跟踪的更改,而我没有告诉它这样做。

我尝试了各种不同的方法来解决此问题。

在关闭打开新文件时打开的“用户”表单之前,请添加此行

 ActiveDocument.TrackRevisions = False

我也尝试了一个if语句

if(ActiveDocument.TrackRevisions) then
    ActiveDocument.TrackRevisions = False
end if

我也尝试这样做,以便将其插入“ Microsoft Word Objects”文件下的“ ThisDocument”部分中,甚至根本不涉及用户表单,而完全不涉及文档本身。这是那里的东西。

Private Sub Document_New()
    UserFormInfo.Show
    'ActiveDocument.Bookmarks("cursor").Select
    ActiveDocument.TrackRevisions = False
    ActiveDocument.Save
End Sub

我希望关闭跟踪的更改,但是不会发生。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

What ended up working for me is I had to remake my template. I had to export my user form so that it was fully removed from all my word files and then remake the template, after that, I had no problem with tracked changes turning on when I ran my macro to open this template. I believe it was a setting I must have had turned on when I had made my template.