View Full Version : Need help with table formatting macro
JRobinson22
01-27-2013, 12:42 PM
Hi - I could use some assistance with a table formatting macro I use. It's part of a larger macro that I run all at once. The issue is that another part of the macro is indenting all paragraphs with Times New Roman font .5 inches, and my table macro is indent all table rows .5 inches. So when I run the overall macro, the Times New Roman font in the table is indented too far over. I'm trying to figure out how to move the font within my tables back over to the standard indent of .5 inches. Here's my table macro Any help to fix this without impacting the indent on the rest of my Times New Roman font paragraphs (which is not in tables) would be greatly appreciated. thanks!
table macro:
Dim oTb As Table
For Each oTb In ActiveDocument.Tables
With oTb
.Style = "Table Elegant"
.Rows.LeftIndent = InchesToPoints(0.5)
.AutoFitBehavior (wdAutoFitContent)
End With
Next oTb
End Sub
gmaxey
01-27-2013, 12:50 PM
Don't indent paragraphs within tables:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oPar As Paragraph
For Each oPar In ActiveDocument.Paragraphs
If Not oPar.Range.Information(wdWithInTable) Then
oPar.Indent
End If
Next oPar
End Sub
JRobinson22
01-27-2013, 01:34 PM
Greg - thanks very much for your reply. you were kind enough last weekend to help me with several different parts of macro I use at my company to format long documents. Is there any way the macro you developed just now could be worked into the other one you developed for me last weekend? I'd be looking for it to indent all times new roman font except if it's in a table. Below is the macro you did for me last weekend:
Sub TNRIndent()
Dim oPar As Word.Paragraph
For Each oPar In ActiveDocument.Paragraphs
If oPar.Range.Font.Name = "Times New Roman" Then
oPar.LeftIndent = InchesToPoints(0.5)
End If
Next oPar
End Sub
gmaxey
01-27-2013, 01:39 PM
J,
Sub TNRIndent()
Dim oPar As Word.Paragraph
For Each oPar In ActiveDocument.Paragraphs
If Not oPar.Range.Information(wdWithInTable) Then
If oPar.Range.Font.Name = "Times New Roman" Then
oPar.LeftIndent = InchesToPoints(0.5)
End If
End If
Next oPar
End Sub
JRobinson22
01-27-2013, 02:50 PM
thanks Greg! can you look at one more thing for me. You wrote the below macro for me last weekend. The only issue I'm facing is I often work with multi-level lists, if I'm working with a multi-level list I want sub-bullets to maintain their indent. can the below macro be modified to achieve this?
Sub bulletindent()
Dim LP As Paragraph
For Each LP In ActiveDocument.ListParagraphs
LP.Indent
Next LP
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.