View Single Post
 
Old 01-29-2021, 02:59 AM
Shelley Lou Shelley Lou is offline Windows 10 Office 2016
Expert
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA convert to table - format Column 1

Hi Guys, I have a macro that converts text to table format which works fine but I want to fine tune it a bit. Column 1 is set to 2.7 width (house style). I want to further format Column 1 to be left aligned (not justified) and indented to 1". I've tried all sorts within the macro but nothing seem to be working and I would be very grateful if someone could help me. Many thanks, Shelley

Code:
Sub DPU_Tables()
    Selection.WholeStory
    Selection.Font.Name = "Arial"
    Selection.Font.Size = 10
    With Selection.ParagraphFormat
        .SpaceBefore = 0
        .SpaceBeforeAuto = False
        .SpaceAfter = 9
        .SpaceAfterAuto = False
        .LineSpacingRule = wdLineSpaceAtLeast
        .LineSpacing = 15
        .LineUnitBefore = 0
        .LineUnitAfter = 0
    End With
    Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
    Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2, _
        NumRows:=8, AutoFitBehavior:=wdAutoFitFixed
    With Selection.Tables(1)
        .Style = "Table Grid"
        .ApplyStyleHeadingRows = True
        .ApplyStyleLastRow = False
        .ApplyStyleFirstColumn = True
        .ApplyStyleLastColumn = False
    End With
   Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
    Selection.Columns(1).PreferredWidth = InchesToPoints(2.7)
    Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
    Selection.Columns(2).PreferredWidth = InchesToPoints(3.63)
    Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
End Sub
Reply With Quote