Article ID: 179338
Article Last Modified on 1/22/2007
Sub UnlinkFieldsinFooter()
' Switch to document footer.
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or _
ActiveWindow.ActivePane.View.Type = wdOutlineView Or _
ActiveWindow.ActivePane.View.Type = wdMasterView Then
ActiveWindow.ActivePane.View.Type = wdPageView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
' Select all text in the footer.
Selection.WholeStory
' Loop through fields in selection.
For Each afield In Selection.Fields
' If field type is a REF field.
If afield.Type = wdFieldRef Then
' Unlink the field.
afield.Unlink ' <--- Word stops responding at this line.
End If
' Reselect all text in the footer.
Selection.WholeStory
Next afield
Selection.Collapse
End Sub
Sub UnlinkFieldsinFooter()
' Switch to document footer.
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
' Select all text in the footer.
Selection.WholeStory
' Loop through fields in selection.
For Each afield In Selection.Fields
' If field type is a REF field.
If afield.Type = wdFieldRef Then
' Select the current field.
afield.Select
'Unlink the currently selected field.
Selection.Field(1).Unlink
End If
' Reselect all text in the footer.
Selection.WholeStory
Next afield
' Close footer return to document
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: kbdtacode kbmacro vba hang hung crash crashed locks locked frozen freezes crashing quit quits stopped crashes auto lockup freeze break won't respond waiting near memory stops responding hangs lock up fail
Keywords: kbbug kbdtacode kbmacroexample KB179338