Consulting

Results 1 to 3 of 3

Thread: Help with VBA

  1. #1
    VBAX Newbie
    Joined
    Feb 2020
    Posts
    1
    Location

    Help with VBA

    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
    Last edited by WJSwan; 02-28-2020 at 02:51 AM. Reason: Specify the MS Word version.

  2. #2
    VBAX Contributor
    Joined
    Jun 2014
    Posts
    107
    Location
    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

  3. #3
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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/...in-ms-word-vba
    and:
    https://www.msofficeforums.com/word-...tting-vba.html
    Kindly read VBA Express' policy on Cross-Posting in Rule 3: http://www.vbaexpress.com/forum/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.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •