如何使用 VBA 自动调整/调整 Lotus 中表的列大小?
我正在编写一个 VBA 脚本来创建和创建通过电子邮件发送数据表。虽然它确实有效,但它也很难看。我想做的一件事是调整这些列的大小,这样它们就不会占据页面的整个宽度。
“自动调整列大小”选项会很好,但我在 API 中没有看到任何地方。或者,我愿意手动设置每列的宽度。有人可以告诉我需要添加什么代码吗?
Dim rtNav As NotesRichTextNavigator
Dim rtTbl As NotesRichTextTable
Dim TblHeader_FontStyle As NotesRichTextStyle
Dim TblBody_BackgroundStyle As NotesRichTextStyle
Dim TblHeader_BackgroundStyle As NotesColorObject
Dim TblBody_FontStyle As NotesColorObject
Sub AppendTable()
'Define styles
Set TblHeader_BackgroundStyle = NtSession.CreateColorObject
TblHeader_BackgroundStyle.NotesColor = COLOR_DARK_BLUE
Set TblHeader_FontStyle = NtSession.CreateRichTextStyle
TblHeader_FontStyle.NotesColor = COLOR_WHITE
TblHeader_FontStyle.FontSize = 8
Set TblBody_FontStyle = NtSession.CreateColorObject
TblBody_FontStyle.NotesColor = COLOR_WHITE
Set TblBody_BackgroundStyle = NtSession.CreateRichTextStyle
TblBody_BackgroundStyle.NotesColor = COLOR_BLACK
TblBody_BackgroundStyle.FontSize = 10
'-----------------------------------------------------
'Make table structure
NtBod.AppendTable lRowCount:=1, lColumnCount:=5
Set rtNav = NtBod.CreateNavigator
Set rtTbl = rtNav.GetFirstElement(RTELEM_TYPE_TABLE)
rtTbl.Style = TABLESTYLE_TOP
Call NtBod.AppendStyle(TblHeader_FontStyle)
Call rtTbl.SetColor(TblHeader_BackgroundStyle)
rtNav.FindFirstElement (RTELEM_TYPE_TABLECELL)
'The rest of the procedure to navigate the table and insert the data goes here
I am coding up a VBA script to create & email a table of data. And while it does work, it's also ugly. One thing I'd like to do is resize these columns so they don't take up the entire width of the page.
The "autosize column" option would be nice, except I don't see anywhere in the API. Alternatively, I'm open to manually setting the widths of each column. Can someone tell me what code I need to add?
Dim rtNav As NotesRichTextNavigator
Dim rtTbl As NotesRichTextTable
Dim TblHeader_FontStyle As NotesRichTextStyle
Dim TblBody_BackgroundStyle As NotesRichTextStyle
Dim TblHeader_BackgroundStyle As NotesColorObject
Dim TblBody_FontStyle As NotesColorObject
Sub AppendTable()
'Define styles
Set TblHeader_BackgroundStyle = NtSession.CreateColorObject
TblHeader_BackgroundStyle.NotesColor = COLOR_DARK_BLUE
Set TblHeader_FontStyle = NtSession.CreateRichTextStyle
TblHeader_FontStyle.NotesColor = COLOR_WHITE
TblHeader_FontStyle.FontSize = 8
Set TblBody_FontStyle = NtSession.CreateColorObject
TblBody_FontStyle.NotesColor = COLOR_WHITE
Set TblBody_BackgroundStyle = NtSession.CreateRichTextStyle
TblBody_BackgroundStyle.NotesColor = COLOR_BLACK
TblBody_BackgroundStyle.FontSize = 10
'-----------------------------------------------------
'Make table structure
NtBod.AppendTable lRowCount:=1, lColumnCount:=5
Set rtNav = NtBod.CreateNavigator
Set rtTbl = rtNav.GetFirstElement(RTELEM_TYPE_TABLE)
rtTbl.Style = TABLESTYLE_TOP
Call NtBod.AppendStyle(TblHeader_FontStyle)
Call rtTbl.SetColor(TblHeader_BackgroundStyle)
rtNav.FindFirstElement (RTELEM_TYPE_TABLECELL)
'The rest of the procedure to navigate the table and insert the data goes here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AppendTable
方法中有一个参数,可让您指定每列的样式,包括宽度。来自 AppendTable 方法文档:
There is a parameter in the
AppendTable
method that lets you specify the style for each column, including the width.From the AppendTable method documentation: