K
killajoules
Hi, I have a Word document linked to an Excel model.
I use the following macro to automatically break all the links in th
document when the file is closed. Unfortunately, it is also stoppin
the table of contents from being updatable. Is it possible so tha
only the links in the body and footers is broken, and the page number
and the table of contents remain the same? Thanks in advance,
Sub AutoClose()
' AutoClose Macro
'
With ActiveDocument.Range.Fields
.Unlink
Dim oField As Field
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oHeader In oSection.Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
oField.Unlink
Next oField
End If
Next oHeader
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
oField.Unlink
Next oField
End If
Next oFooter
Next oSection
End With
End Su
I use the following macro to automatically break all the links in th
document when the file is closed. Unfortunately, it is also stoppin
the table of contents from being updatable. Is it possible so tha
only the links in the body and footers is broken, and the page number
and the table of contents remain the same? Thanks in advance,
Sub AutoClose()
' AutoClose Macro
'
With ActiveDocument.Range.Fields
.Unlink
Dim oField As Field
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oHeader In oSection.Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
oField.Unlink
Next oField
End If
Next oHeader
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
oField.Unlink
Next oField
End If
Next oFooter
Next oSection
End With
End Su