![]() |
|
#2
|
||||
|
||||
|
That should be fairly straightforward:
Code:
Sub Macro1()
Dim oFld As Field
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
For Each oFld In oStory.Fields
If oFld.Type = wdFieldRef Then
If oFld.Result Like "Part*" Or _
oFld.Result Like "Schedule*" Then
oFld.Unlink
End If
End If
Next oFld
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
For Each oFld In oStory.Fields
If oFld.Type = wdFieldRef Then
If oFld.Result Like "Part*" Or _
oFld.Result Like "Schedule*" Then
oFld.Unlink
End If
End If
Next oFld
Wend
End If
Next oStory
lbl_Exit:
Set oStory = Nothing
Set oFld = Nothing
Exit Sub
End Sub
Code:
Sub Macro2()
Dim oFld As Field
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
For Each oFld In oStory.Fields
If oFld.Type = wdFieldRef Then
Debug.Print oFld.Result
End If
Next oFld
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
For Each oFld In oStory.Fields
If oFld.Type = wdFieldRef Then
Debug.Print oFld.Result
End If
Next oFld
Wend
End If
Next oStory
lbl_Exit:
Set oStory = Nothing
Set oFld = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Determining if an in-text table reference was created with Word's native cross reference feature
|
scienceguy | Excel Programming | 2 | 10-25-2021 04:44 AM |
| Macro for removing cross-reference fields with specific contents | Ulodesk | Word VBA | 5 | 07-13-2017 08:27 AM |
Cross Reference REF fields Unlink
|
mktate | Word VBA | 7 | 06-24-2016 05:55 AM |
Totaling specific configuration selections that cross reference multiple fields (tricky)
|
lonniepoet | Excel Programming | 1 | 06-09-2016 09:54 AM |
| manipulating cross-reference fields | _wim_ | Word | 0 | 12-10-2010 05:52 AM |