看来我的主管想出了一个可以满足我们需求的代码,但是,所有包含的代码对于宏的执行来说可能不是必需的,但他害怕删除任何东西。哈哈!
但我会将它包含在这里,以供那些将来寻找类似 VBA 分辨率的人,甚至是那些能够澄清它并减少编码混乱的人使用。
Sub FillInHelpRemoval()
Dim objFld As FormField
Dim intCount, intLoop As Integer
Dim intNum, intText, intDate, intCheck As Integer
Dim intLen As Integer
Dim intLoop2 As Integer
Dim lngStr As Long
For Each objFld In ActiveDocument.FormFields
intCount = intCount + 1
Next
If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect
On Error Resume Next
For intLoop = 1 To intCount
Select Case True
Case ActiveDocument.FormFields(intLoop).Type = 70 'text
ActiveDocument.FormFields(intLoop).Select
If ActiveDocument.FormFields(intLoop).TextInput.Type = wdDateText Then
ActiveDocument.FormFields(intLoop).Select
With Selection.FormFields(1)
With .TextInput
.EditType Type:=wdRegularText, Default:="", Format:=""
End With
End With
intDate = intDate + 1
Else
If ActiveDocument.FormFields(intLoop).TextInput.Type = wdNumberText Then
ActiveDocument.FormFields(intLoop).Select
With Selection.FormFields(1)
With .TextInput
.EditType Type:=wdRegularText, Default:="", Format:=""
End With
End With
intNum = intNum + 1
End If
End If
Case Else
Debug.Print ActiveDocument.FormFields(intLoop).Type
End Select
Next intLoop
'Call FillInHelpRemoval
For Each objFld In ActiveDocument.FormFields
objFld.Select
With Selection.FormFields(1)
.StatusText = ""
End With
Next
End Sub