我正在写一篇学术论文。会议的组织给了我一个宏列表,用于撰写论文。 当我尝试激活Word中的宏时,出现此错误:
哪个说我有一个未定义的用户定义类型。我该怎么办? 对不起,但我确实是一个新手,以前从未使用过Visual Basic。
代码:
Option Explicit
Private Sub Document_Open()
Dim ur As UndoRecord
Dim objField As Field
On Error Resume Next
Set ur = Application.UndoRecord
ur.StartCustomRecord "Update all fields"
'Update fields
For Each objField In ActiveDocument.Fields
If objField.Type = wdFieldSequence Then
objField.Update
End If
Next
ur.EndCustomRecord
'If no other change is made (except for updating the fields), allow closing without saving
ActiveDocument.Saved = True
'Check for standard page setup
RestorePageSetup
End Sub
答案 0 :(得分:0)
此问题与我的Word版本有关,该版本从2007年更新到2017年,并且宏正常工作。