PDA

View Full Version : Help with VBA



WJSwan
02-28-2020, 02:02 AM
Good day,
I am new to VBA and need some expert help. I have a table (2 columns) which I select and need to set the following:

Whole table:
Set it so that rows can break across pages
Set the font to Verdana
Set border around all cells (i.e. Grid)
Set rows to fit the text
Set cell margins: Top =.05cm, bottom = .05cm, left = .15cm, right, .05cm

Column 1: Set font to size 10Pt, Left align

Column 2: Set font to size 11 pt, justified

I would really appreciate if some can help me with this.

Regards,
Willem

PS. I use Word 2007

heedaf
02-28-2020, 04:25 PM
I would use the record macro feature under View-->Macros to do this. Start recording and make the changes. The following recorded macro should point you in the right direction:

With ActiveDocument.Styles("Table Grid").Table.Condition(wdSECell). _ ParagraphFormat
.LeftIndent = InchesToPoints(0)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
.CollapsedByDefault = False
End With

macropod
02-28-2020, 08:59 PM
WJSwan: You've been advised repeatedly on other forums about the need to provide cross-post links. This one has been cross-posted at:
https://stackoverflow.com/questions/60449321/handling-tables-in-ms-word-vba
and:
https://www.msofficeforums.com/word-vba/44501-handling-table-formatting-vba.html
Kindly read VBA Express' policy on Cross-Posting in Rule 3: http://www.vbaexpress.com/forum/faq.php?faq=new_faq_item#faq_new_faq_item3

Thread closed. Keep up your practices from other forums here, and your account here will be closed, just as it has been at
msofficeforums.