我编写了一个VBA脚本来创建&电子邮件的数据表。虽然它确实有效,但它也很难看。我想要做的一件事是调整这些列的大小,使它们不占据整个页面的宽度。如何使用VBA在Lotus中自动调整/调整表格的列大小?
“autosize column”选项会很好,除非我在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
这就是我一直在寻找的。我有一段时间没有在这个代码上工作,所以我有点生疏。 – PowerUser 2011-05-24 19:17:56
@PowerUser,很高兴听到它! – 2011-05-24 19:25:15