我目前正在运行此代码,但它不起作用。
ObjTable.Cell(3,2).Range.Text = "hello"
objTable.Cell(3,2).range
.Font.Name = "Arial"
.Font.Size = "14"
只有单词出来,而不是单词的格式。
您需要将.Font.Name
和.Font.Size
封装在 with 语句中,如下所示:
ObjTable.Cell(3,2).Range.Text = "hello"
With objTable.Cell(3,2).Range
.Font.Name = "Arial"
.Font.Size = "14"
End With
有关详细信息,请参阅 https://learn.microsoft.com/en-us/office/vba/Language/Reference/User-Interface-Help/with-statement。
更高效:
With objTable.Cell(3,2).Range
.Text = "hello"
.Font.Name = "Arial"
.Font.Size = "14"
End With