在Word 2007及更早的版本中,使用的是複選框型窗體域選項插件;在2010及更新的版本中,使用的是 複選框內容控件。 能夠經過下面的VBA, 批量將舊插件更換爲新插件。 ide
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oFF As FormField
Dim oCC As ContentControl
Dim strText As String
Dim bVal As Boolean
Dim arrVals() As String
Dim lngIndex As Long, lngDDItem As Long
Dim oRng As Range
For lngIndex = ActiveDocument.FormFields.Count To 1 Step -1
Set oFF = ActiveDocument.FormFields(lngIndex)
Select Case oFF.Type
Case 83
ReDim arrVals(1 To oFF.DropDown.ListEntries.Count)
For lngDDItem = 1 To oFF.DropDown.ListEntries.Count
arrVals(lngDDItem) = oFF.DropDown.ListEntries(lngDDItem).Name
Next lngDDItem
strText = oFF.Result
Set oRng = oFF.Range
oFF.Delete
Set oCC = ActiveDocument.ContentControls.Add(wdContentControlDropdownList, oRng)
oCC.DropdownListEntries.Add oCC.PlaceholderText, vbNullString
For lngDDItem = 1 To UBound(arrVals)
oCC.DropdownListEntries.Add arrVals(lngDDItem), arrVals(lngDDItem)
If oCC.DropdownListEntries(oCC.DropdownListEntries.Count).Value = strText Then
oCC.DropdownListEntries(oCC.DropdownListEntries.Count).Select
End If
Next lngDDItem
Case 71
bVal = oFF.CheckBox.Value
Set oRng = oFF.Range
oFF.Delete
Set oCC = ActiveDocument.ContentControls.Add(wdContentControlCheckBox, oRng)
oCC.Checked = bVal
Case 70
strText = oFF.Result
Set oRng = oFF.Range
oFF.Delete
Set oCC = ActiveDocument.ContentControls.Add(wdContentControlText, oRng)
oCC.Range.Text = strText插件
End Select
Next
lbl_Exit:
Exit Subcode
End Suborm