From: Fuzzhead on
I have converted a document from WordPerfect to word and now I am attaching
the correct Heading to the step. The following is an example of what I have.
There is a tab between {LISTUNM 37 \l 2} and Do not exceed...

{LISTUNM 37 \l 2} Do not exceed a steady state running… .

Here is my macro:

SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^dLISTNUM 37 \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

What I end up with is 2 tabs between my heading number and the text. I have
tried several different ways to delete the tab after {LISTUNM 37 \l 2} with
no success. How do I delete that tab before I put in my Heading 2?

From: DA on
Is your TAB part of the LISTNUM field or after it? Actually I can't see
anywhere that you're looking to replace a tab "^t" character as part of your
search in the code you pasted.

I'm also not sure why you're executing the find/replace twice, once with and
once without formatting.

I assume since you mention a heading number that you've got Outline
numbering enabled on your "Heading 2" style. The ouline numbering style
you're using probably has a TAB between the level number and the text, in
which case you'd be getting 2 tabs as described since you're not eliminating
the tab as part of your replace routine.

Anyhow, hope thats been of some help.
Best of luck.
Dennis

"Fuzzhead" wrote:

> I have converted a document from WordPerfect to word and now I am attaching
> the correct Heading to the step. The following is an example of what I have.
> There is a tab between {LISTUNM 37 \l 2} and Do not exceed...
>
> {LISTUNM 37 \l 2} Do not exceed a steady state running… .
>
> Here is my macro:
>
> SearchRange.TextRetrievalMode.IncludeFieldCodes = True
> With SearchRange.Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Text = "^dLISTNUM 37 \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
>
> What I end up with is 2 tabs between my heading number and the text. I have
> tried several different ways to delete the tab after {LISTUNM 37 \l 2} with
> no success. How do I delete that tab before I put in my Heading 2?
>