L
LEU
I have the following macro that converts my old outline numbering (from
WordPerfect) to our new numbering style. The problem is that not all the
procedures have the same old style numbering. Most I can convert using
"^dLISTNUM ^#^# \l 1" and so on. But I have come across a lot that are
“LISTNUM ParaNumbers1 \l 1†or “LISTNUM something elseâ€. Is there a way to
change my macro to catch all the different styles?
Dim SearchRange As Range
Dim HeadingRange As Range
Set SearchRange = ActiveDocument.Range
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 1"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 1")
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 2"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 2")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 3"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 3")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 4"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 4")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 5"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 5")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 6"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 6")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 7"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 7")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
WordPerfect) to our new numbering style. The problem is that not all the
procedures have the same old style numbering. Most I can convert using
"^dLISTNUM ^#^# \l 1" and so on. But I have come across a lot that are
“LISTNUM ParaNumbers1 \l 1†or “LISTNUM something elseâ€. Is there a way to
change my macro to catch all the different styles?
Dim SearchRange As Range
Dim HeadingRange As Range
Set SearchRange = ActiveDocument.Range
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 1"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 1")
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 2"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 2")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 3"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 3")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 4"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 4")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 5"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 5")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 6"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 6")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM ^#^# \l 7"
.Replacement.Text = ""
.Replacement.Style = ActiveDocument.Styles("Heading 7")
.Forward = True
.Format = True
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Format = False
.Execute Replace:=wdReplaceAll
End With