Sub create()
'
' create 宏
'
'
Dim docActive As Document
Dim tblNew As Table
Dim celTable As Cell
Dim intCount As Integer
Set docActive = ActiveDocument
'Set tblNew = docActive.Tables.Add( _
Range:=docActive.Range(Start:=0, End:=0), NumRows:=3, _
NumColumns:=4)
Set tblNew = docActive.Tables.Add( _
Range:=Selection.Range, NumRows:=2, _
NumColumns:=2)
intCount = 1
tblNew.Range.Cells(1).Range.InsertAfter "内容"
tblNew.Range.Cells(2).Range.InsertAfter "备注"
' For Each celTable In tblNew.Range.Cells
' celTable.Range.InsertAfter "Cell " & intCount
' intCount = intCount + 1
' Next celTable
tblNew.Range.Cells(1).Shading.ForegroundPatternColor = wdColorLightOrange
tblNew.Range.Cells(2).Shading.ForegroundPatternColor = wdColorLightOrange
tblNew.Range.Cells(1).Range.Font.Size = 12
tblNew.Range.Cells(2).Range.Font.Size = 12
tblNew.Range.Cells(1).Range.Bold = True
tblNew.Range.Cells(2).Range.Bold = True
tblNew.Range.Cells(1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
tblNew.Range.Cells(2).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
tblNew.Range.Cells(2).Shading.ForegroundPatternColor = wdColorLightOrange
With tblNew.Borders
.InsideLineStyle = wdLineStyleSingle
.OutsideLineStyle = wdLineStyleSingle
End With
tblNew.Columns(1).Width = 300
tblNew.Columns(2).Width = 120
tblNew.Rows(2).Height = 200
' tblNew.AutoFormat Format:=wdTableFormatColorful2, _
' ApplyBorders:=True, ApplyFont:=True, ApplyColor:=True
End Sub
2021-09-03 Word创建表格
最新推荐文章于 2022-02-12 00:00:00 发布