Add/Remove SEQ field and text in identical Styles

M

Matt C

Hi folks. The code below adds text and sequential numbering using a
combination of REF with SEQ or AUTONUM to a specific paragraph Style.
I would very much appreciate some help in automating this so that I
can add (and later remove) the text and numbering from the specific
Style throughout a document with one click. With this in mind, I'm
not sure which option out of SEQ or AUTONUM is best to use.

If Selection.Style = ActiveDocument.Styles("Scene Heading") Then
Selection.HomeKey Unit:=wdLine
Selection.TypeText Text:="SCENE "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"REF Episode", PreserveFormatting:=False
Selection.TypeText Text:="-"

'Option #1
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"SEQ SceneNumber\* Arabic", PreserveFormatting:=True
Selection.TypeText Text:="."

'Option #2
' Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"AUTONUM ", PreserveFormatting:=False

Selection.TypeText Text:=vbTab
End If


In theory, I'm trying to do a more advanced version of the code below
which just does a basic numbered/un-numbered Style replacement:

With ActiveDocument.Content.Find
..ClearFormatting
..Style = ActiveDocument.Styles("Scene Heading")
..Replacement.Style = wdStyleHeading1
..Wrap = wdFindContinue
..Execute , , , , , , , , , , wdReplaceAll
End With
End Sub


Thanks in advance for your help.
Matt C
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top