Table formatting question

F

Fuzzhead

Tony Jollans wrote the following macro to help me with renaming the style in
the tables in my documents. It works great except for the existing formatting
is lost. After it runs everything is right justified. Is there a way to
modify this to keep the existing formatting? So words that are centered stay
centered; words that are left justified stay left justified and words that
are right justified stay right justified.


Set oDoc = Word.ActiveDocument
Selection.GoTo what:=wdGoToPage, _
which:=wdGoToAbsolute, Count:=2
For Each T In ActiveDocument.Tables
For Each P In T.Range.Paragraphs
If P.Style = "Normal" Then P.Style = "tNormal"
Next P, T
Selection.HomeKey wdStory
 
F

Fuzzhead

I got it. The following works:

Set oDoc = Word.ActiveDocument
Selection.GoTo what:=wdGoToPage, _
which:=wdGoToAbsolute, Count:=2
For Each T In ActiveDocument.Tables
For Each P In T.Range.Paragraphs
If P.Style = "Normal" And P.Alignment = wdAlignParagraphCenter Then
P.Style = "tcNormal"
ElseIf P.Style = "Normal" And P.Alignment = wdAlignParagraphLeft Then
P.Style = "tlNormal"
ElseIf P.Style = "Normal" And P.Alignment = wdAlignParagraphRight Then
P.Style = "trNormal"
End If
Next P, T
Selection.HomeKey wdStory
 

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