运行MS Word,宏字体

时间:2018-10-09 19:05:49

标签: vba if-statement fonts ms-word word-vba

(耐心我的中风)

在MS Word宏中创建表的代码是什么?我需要制作表格字体。如果……然后……其他(阿罗尼,世纪哥特人,阿里亚尔)。

enter image description here

帮助?

对不起:(我可能会合并:

enter image description here

1 个答案:

答案 0 :(得分:0)

这应该让您入门

Option Explicit

Sub TestInsertTable()

    InsertTableAtSelection "Awesome", "Love," & vbCrLf & "Mum", "I miss you"

End Sub

Sub InsertTableAtSelection(LeftText As String, MidText As String, RightText As String)
' Inserts a 1 row, 3 column table at the cursor or start of the selection

Dim InsertHere                          As Word.Range
Dim my_Table                            As Word.Table
    Set InsertHere = Selection.Range
    InsertHere.Collapse direction:=wdCollapseStart
    Set my_Table = InsertHere.Tables.Add(Range:=InsertHere, numrows:=1, numcolumns:=3)

    With my_Table.Range.Cells(1).Range
        .ParagraphFormat.Alignment = wdAlignParagraphCenter
        .Text = LeftText
        .Font.Name = "Aharoni"
    End With

    With my_Table.Range.Cells(2).Range
        .ParagraphFormat.Alignment = wdAlignParagraphCenter
        .Text = MidText
        .Font.Name = "Century Gothic"
    End With

    With my_Table.Range.Cells(3).Range
        .ParagraphFormat.Alignment = wdAlignParagraphCenter
        .Text = RightText
        .Font.Name = "Arial"
    End With

    my_Table.Borders.Enable = True

End Sub
相关问题