J
jbc
Hi,
The following code is working perfectly for me except when it hits a table.
I would like it to SKIP tables and not put the sequential number field there.
I only want it if the paragraph style is Normal and not in a table.
Right now it is placing sequential numbers in each cell of the first table.
I'm getting the following error message when it gets to the end of the first
row:
Run-time error 5251. This is not a valid action for the end of a row.
I've tried several different options to get this to work. I've been looking
at it all day and am still not getting anywhere.
Any help would be greatly appreciated.
Thanks.
jbc
*********************************************
Dim oPar As Paragraph
Dim oRng As Range
ActiveWindow.View.ShowFieldCodes = True
For Each oPar In ActiveDocument.Paragraphs
If oPar.Style = "Normal" Then
If Not Mid(oPar.Range.Text, 3, 3) = "SEQ" Then
oPar.Range.InsertBefore vbTab
Set oRng = oPar.Range.Duplicate
oRng.Collapse direction:=wdCollapseStart
ActiveDocument.Fields.Add Range:=oRng, Type:=wdFieldSequence,
Text:= _
"Paragraph \# ""[0000]"" \n "
oRng.Paragraphs(1).Range.Fields(1).Result.Font.Bold = True
End If
End If
Next oPar
ActiveWindow.View.ShowFieldCodes = False
ActiveDocument.Fields.Update
*************************************************
The following code is working perfectly for me except when it hits a table.
I would like it to SKIP tables and not put the sequential number field there.
I only want it if the paragraph style is Normal and not in a table.
Right now it is placing sequential numbers in each cell of the first table.
I'm getting the following error message when it gets to the end of the first
row:
Run-time error 5251. This is not a valid action for the end of a row.
I've tried several different options to get this to work. I've been looking
at it all day and am still not getting anywhere.
Any help would be greatly appreciated.
Thanks.
jbc
*********************************************
Dim oPar As Paragraph
Dim oRng As Range
ActiveWindow.View.ShowFieldCodes = True
For Each oPar In ActiveDocument.Paragraphs
If oPar.Style = "Normal" Then
If Not Mid(oPar.Range.Text, 3, 3) = "SEQ" Then
oPar.Range.InsertBefore vbTab
Set oRng = oPar.Range.Duplicate
oRng.Collapse direction:=wdCollapseStart
ActiveDocument.Fields.Add Range:=oRng, Type:=wdFieldSequence,
Text:= _
"Paragraph \# ""[0000]"" \n "
oRng.Paragraphs(1).Range.Fields(1).Result.Font.Bold = True
End If
End If
Next oPar
ActiveWindow.View.ShowFieldCodes = False
ActiveDocument.Fields.Update
*************************************************