Paragraph formatting

L

LEU

I am converting WordPerfect documents to Word documents. Part of my macro
that cleans up the document after the conversion is to redo the outline
numbering. So what I end up with looks like this:

1.1 Compressor use for Air Stand Blowdown and Testing

NOTE:This section is to be used as required in
conjunction with
Sections 7.5 and 7.8, for air stand
blowdown and testing,
respectively. The use of the air
compressor is to
minimize the amount of nitrogen expended
to fully fill
the accumulator volume.

1.1.1 Line up compressor to accumulator as follows:

Is there a way to make the paragraphs between the numbers to have the same
formatting as the number above it? So it would look like this:

1.1 Compressor use for Air Stand Blowdown and Testing

NOTE:This section is to be used as required in conjunction with
Sections 7.5 and 7.8, for air stand blowdown and testing,
respectively.
The use of the air compressor is to minimize the amount of nitrogen
expended to fully fill the accumulator volume.

1.2.1 Line up compressor to accumulator as follows:

LEU
 
L

LEU

What I end up with looks like this:

1.1 Compressor use for Air Stand Blowdown and Testing

NOTE: This section is to be used as required in . . .

1.1.1 Line up compressor to accumulator as follows


Want it to look like this:

1.1 Compressor use for Air Stand Blowdown and Testing

NOTE: This section is to be used as required in conjunction with...

1.1.1 Line up compressor to accumulator as follows

LEU
 
L

LEU

I think this explains it better. . .

Here is my macro that converts the old outline numbering and style to the
new numbering and style.

Set SearchRange = ActiveDocument.Range
SearchRange.TextRetrievalMode.IncludeFieldCodes = True
With SearchRange.Find
.Text = "^dLISTNUM"
Do While .Execute(Forward:=True) = True
SearchRange.Select
SearchRange.Style = ActiveDocument.Styles("Heading " _
& SearchRange.Characters.Last.Previous)
SearchRange.Text = ""
SearchRange.Collapse Direction:=wdCollapseEnd
Loop
End With

How do I get all the paragraphs between the headings to have the same
paragraph formatting as the heading?
 
H

Helmut Weber

Hi LEU,

assuming, that every range of consecutive
paragraphs of style "Normal" is preceded
by a heading paragraph, the following
does hopefully set the left indent of
consecutive paragraphs of style "Normal"
to the position of the first tab of
the preceding paragraph, which is assumed
to be a heading paragraph, as mentioned above.

Sub Test5xxx()
Dim rTmp As Range
Dim rTmp1 As Range
Set rTmp = ActiveDocument.Range
With rTmp.Find
.Style = "Normal"
While .Execute
Set rTmp1 = rTmp.Duplicate
rTmp1.Select ' for testing
Do
While Not (rTmp1.Paragraphs.Last.Next Is Nothing)
If rTmp1.Paragraphs.Last.Next.Style = "Normal" Then
rTmp1.End = rTmp1.Paragraphs.Last.Next.Range.End
rTmp1.Select ' for testing
Else
Exit Do
End If
If rTmp1.Paragraphs.Last.Next Is Nothing Then
Exit Do
End If
Wend
Loop
rTmp1.ParagraphFormat.LeftIndent = _
rTmp1.Paragraphs.First.Previous.TabStops(1).Position
rTmp.Start = rTmp1.End
rTmp.End = ActiveDocument.Range.End
If rTmp1.Paragraphs.Last.Next Is Nothing Then
Exit Sub
End If
Wend
End With

End Sub

Surely improvable in many ways.

I needed a night's sleep to get it working.
Especially to find a terminating condition
was very hard, at least for me.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
L

LEU

Hi Helmut,

Thank you for your help. All my documents have a cover page and your macro
worked as long as I removed the first page. Is there a way to have this start
on the second page of the document?

LEU
 
H

Helmut Weber

Hi LEU,

Set rTmp = ActiveDocument.Range

is the initial range.

If you got to page 2 after that,

Selection.GoTo _
what:=wdGoToPage, _
which:=wdGoToAbsolute, _
Count:=2

and change the range, like that

rTmp.Start = Selection.Start
rTmp.End = ActiveDocument.Range.End

it might work.

Its hard to check without testing material.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
L

LEU

Helmut,

This is very hard. Your changes worked but I have other problems with it
now. I have tables in some of the documents and it changes them too. If you
would like I could send you one of my documents for you to play with.


LEU
 
H

Helmut Weber

Hi LEU
Helmut,

This is very hard. Your changes worked but I have other problems with it
now. I have tables in some of the documents and it changes them too. If you
would like I could send you one of my documents for you to play with.

Do it.

red<dot>sys<at>t-online<dot>de

Start the topic line with [MVP],
otherwise the mail might not get through.
--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
L

LEU

Helmut,

I sent it to you.

LEU


Helmut Weber said:
Hi LEU


Do it.

red<dot>sys<at>t-online<dot>de

Start the topic line with [MVP],
otherwise the mail might not get through.
--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
H

Helmut Weber

Hi LEU,

the doc you sent me is a nightmare.

The macro works reasonably well,
of you start at page 3.
It seems, it even terminates.

However, there are so many irregularities,
direct formatting regarding ranges titled
"Note", "Warning", "Caution",
that there is no economically justifiable way
to approach all programmatically.

Means programming it would take longer,
if possible at all, than doing it by hand.

Especially empty paragraphs are a drag.

To reformat all is a job I wouldn't go for.

Sorry, my English is limited.


--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
L

LEU

Hi Helmut,

Thank you for trying. I thought that it would be very hard to do. We will
just keep doing it by hand.

Thanks again

LEU
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top