我在表中有Aligment的问题,我通过vba excel创建。代码可以工作,但它不会改变表格中的格式。选择正在进行中。
objTable.Columns(5).Select
With objWord.Selection
HorizontalAlignment = xlCenter
VerticalAlignment = xlCenter
End With
Create a Word document with table via vba excel:
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Activate
Set objDoc = objWord.Documents.Add(path)
Set objRange = objDoc.Range
objRange.Collapse Direction:=wdCollapseEnd
objDoc.Tables.Add objRange, number_row, number_column
Set objTable = objDoc.Tables(2)
答案 0 :(得分:0)
假设您有对Word对象库的引用,则需要以下内容:
objTable.Columns(5).Select
With objWord.Selection
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Cells.VerticalAlignment = wdCellAlignVerticalCenter
End With
请注意,您使用的是Word常量,而不是Excel&#39。