F
Fuzzhead
We are converting thousands of documents from WordPerfect to Word. I have
write with the help from this site to clean up the bulk of the problems
created from the conversion. I found one that Russ wrote that works for most
of mine. The majority of the converted documents come across with the code as
{LISTNUM # \l #} or {LISTNUM ## \l #} where # is some number like in Russ's
macro. The problem is that there are a large number that have come across
with a second word after LISTNUM like {LISTNUM LEGAL \l #} or {LISTNUM
Paranum # \l #}. Is there a way to revise this macro to look for just the
word LISTNUM and the \l #, skipping the stuff in the middle?
Set SearchRange = ActiveDocument.Range
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.Wrap = wdFindStop
.Format = True
.Text = "^dLISTNUM ^# \l ^#"
While .Execute
'Select Found Text
SearchRange.Select
'Avoid Style Collection Error If Number is 0
If SearchRange.Characters.Last.Previous.Text = "0" Then
SearchRange.Characters.Last.Previous.Text = "1"
End If
'Apply Heading Format To Whole Paragraph Using Found Text Number
Selection.Paragraphs(1).Style = ActiveDocument.Styles("Heading " _
& SearchRange.Characters.Last.Previous)
'Delete Found Text
SearchRange.Text = ""
'Reset Range For Next Search Area
SearchRange.SetRange Start:=SearchRange.End, _
End:=ActiveDocument.Range.End
Wend
End With
Fuzzhead
write with the help from this site to clean up the bulk of the problems
created from the conversion. I found one that Russ wrote that works for most
of mine. The majority of the converted documents come across with the code as
{LISTNUM # \l #} or {LISTNUM ## \l #} where # is some number like in Russ's
macro. The problem is that there are a large number that have come across
with a second word after LISTNUM like {LISTNUM LEGAL \l #} or {LISTNUM
Paranum # \l #}. Is there a way to revise this macro to look for just the
word LISTNUM and the \l #, skipping the stuff in the middle?
Set SearchRange = ActiveDocument.Range
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.Wrap = wdFindStop
.Format = True
.Text = "^dLISTNUM ^# \l ^#"
While .Execute
'Select Found Text
SearchRange.Select
'Avoid Style Collection Error If Number is 0
If SearchRange.Characters.Last.Previous.Text = "0" Then
SearchRange.Characters.Last.Previous.Text = "1"
End If
'Apply Heading Format To Whole Paragraph Using Found Text Number
Selection.Paragraphs(1).Style = ActiveDocument.Styles("Heading " _
& SearchRange.Characters.Last.Previous)
'Delete Found Text
SearchRange.Text = ""
'Reset Range For Next Search Area
SearchRange.SetRange Start:=SearchRange.End, _
End:=ActiveDocument.Range.End
Wend
End With
Fuzzhead