Hi Tony,
I agree that numbering would would be better than code but ...
How do you format numbering to have leading zeroes like that?
Mmmm, in the light of day, I see what you're getting at...
In that case, I'd probably be inclined to go with SEQ fields so
that updating the document would be easier. Just add fields
where none currently are present. Casey, how about this for
starters:
Sub NumberAllParas()
Dim para As Word.Paragraph
Dim doc As Word.Document
Dim rng As Word.Range
Dim numFormat As String
Dim fieldcode As String
numFormat = "[00000] "
fieldcode = "SEQ paras \# " & numFormat
Set doc = ActiveDocument
For Each para In doc.Paragraphs
Set rng = para.Range
rng.TextRetrievalMode.IncludeFieldCodes = True
If rng.Words(1).Fields.Count = 0 Then
InsertSEQField rng, fieldcode
'Check that it's not an SEQ field from this sequence
ElseIf rng.Words(1).Fields(1).Code <> _
" " & fieldcode & " " Then
InsertSEQField rng, fieldcode
End If
Next
End Sub
Private Sub InsertSEQField(rng As Word.Range, _
fieldText As String)
rng.Collapse wdCollapseStart
'In case the range is invalid for inserting a field
On Error Resume Next
rng.Fields.Add Range:=rng, _
Text:=fieldText, _
PreserveFormatting:=False
On Error GoTo 0
End Sub
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8
2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail
![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)