更改表的第一行的行高度和段落线间距
我将一组从Excel复制到Word,并格式化每个表格。
For t = 1 To 6
With appWD.Selection.Tables(t)
.TopPadding = 0
.BottomPadding = 0
.LeftPadding = 0.11
.RightPadding = 0
.Spacing = 0
.AllowPageBreaks = True
.AllowAutoFit = True
.Rows.SetHeight RowHeight:=12, HeightRule:=2
End With
Next t
为了容纳较大的字体,我需要更改第一行的行高度,并更改段落线间距。
这件代码无法做到这一点。
For t = 1 To 6
With appWD.Selection.Tables(t).Rows(1)
.SetHeight RowHeight:=18
.ParagraphFormat.LineSpacing = 15
End With
Next t
我正在Mac上运行Excel/Word 2016。
I copied a set of tables from Excel into Word and formatted each one.
For t = 1 To 6
With appWD.Selection.Tables(t)
.TopPadding = 0
.BottomPadding = 0
.LeftPadding = 0.11
.RightPadding = 0
.Spacing = 0
.AllowPageBreaks = True
.AllowAutoFit = True
.Rows.SetHeight RowHeight:=12, HeightRule:=2
End With
Next t
To accommodate a larger font, I need to change the row height of the first row and also to change the paragraph line spacing.
This piece of code fails to do this.
For t = 1 To 6
With appWD.Selection.Tables(t).Rows(1)
.SetHeight RowHeight:=18
.ParagraphFormat.LineSpacing = 15
End With
Next t
I'm running Excel/Word 2016 on a Mac.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用AppWD.Selection是糟糕的实践。您有一个要处理的开放文档,因此请直接参考。例如:
请注意,第1行方法的合适的Heightrule参数包含。还请注意,所有处理都是在单个循环中完成的,而不是您使用的代码两个循环。
Using appWD.Selection is poor practice. You have an open document you want to work on, so reference that directly. For example:
Note the the inclusion of the appropriate HeightRule argument for the Row 1 SetHeight method. Note also that all the processing is done in a single loop, rather than the two loops your code used.