我正在尝试从 Excel VBA 设置单词表的边框。许多网站建议如下:
wrdTable.Borders(wdBorderTop).LineStyle = wdLineStyleSingle
Run Code Online (Sandbox Code Playgroud)
但是在尝试时出现错误(集合的请求成员不存在)。但是,我可以使用以下代码带内边框:
wrdTable.Borders(xlDiagonalUp).LineStyle = xlContinuous
Run Code Online (Sandbox Code Playgroud)
同样我试过:
wrdTable.Borders(xlEdgeTop).LineStyle = xlContinuous
Run Code Online (Sandbox Code Playgroud)
带上边框,但我得到对角线。如何在我的单词表中应用边框(内边框和外边框)?我正在使用 Office 2007。
这些文章将使您走上正轨:
http://www.shaunkelly.com/word/formatting/border-basics.html
http://www.shaunkelly.com/word/styles/borders-in-table-styles.html
假设您wrdTable已正确设置为 msword 文档中的 table 对象,您有几个选项:
wrdTable.Borders.Enable = True
Run Code Online (Sandbox Code Playgroud)
将此设置为 True 将对象的边框设置为与此对象的当前默认边框属性相同的线型和线宽。
否则指导方针是
这是更详细的版本:
With wrdTable.Borders
.OutsideLineStyle = wdLineStyleSingle
.OutsideLineWidth = wdLineWidth075pt
.OutsideColor = wdDarkRed
End With
Run Code Online (Sandbox Code Playgroud)
有关语法的其他参考,请参阅此页面:
http://msdn.microsoft.com/en-us/library/office/aa221392(v=office.11).aspx
(请注意,我是从手机输入此代码的,因此未经测试)