打開 M$ Word 文檔的時候自動更新域
17 March 2014
今天編輯設計文檔的時候,每次更新了文檔標題信息后要選中標題域(Field)點擊更新才可以更新到最新的字符。Google 了一下發現一個 VBS 腳本1可以做到每次打開文檔的時候自動把文檔内的域更新。
Sub AutoOpen() ' ' AutoOpen Macro ' ' Dim aStory As Range Dim aField As Field ' Check that document is not in Protected View before doing anything If Application.ActiveProtectedViewWindow Is Nothing Then For Each aStory In ActiveDocument.StoryRanges For Each aField In aStory.Fields aField.Update Next aField Next aStory ' set document as unchanged (prevents save dialog popping up when 'closing) - further changes will set this back ActiveDocument.Saved = True End If End Sub