Thread: [Solved] Macro to delete tabs in Word
View Single Post
 
Old 12-17-2020, 10:07 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 Macro to delete tabs in Word

I have updated the code to now convert the text to a 2 column table, I have set the width of both columns, removed the borders of the table to No Border and have justified the text. How can I set Column 1 to be left aligned but keep Column 2 as justified. I also need to include font as Arial 10 with line spacing of At Least 15pt. Can anyone help at all?

Code:
Sub DPU_converttexttotable()
   Selection.WholeStory
   'convert text to table 2 columns'
    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
     'width of column 1 to be 2.7 inches'
    Selection.Columns(1).PreferredWidth = InchesToPoints(2.7)
    Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
    'width of column 2 to be 3.63 inches'
      Selection.Columns(2).PreferredWidth = InchesToPoints(3.63)
      'alignment of column 2 is Justify'
      Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    'remove borders of entire table'
    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