0

我正在使用 VBS 在 Outlook 中创建签名以推送给我们的用户。签名中有表格,因此我可以将徽标/用户信息与徽标顶部的标准文本并排放置。(原始表格代码在这里找到:http ://www.vbforums.com/showthread.php?526706-resolved-question-with-tables-in-vbscript-for-AD-signature )

下面是写入 doc 文件的代码片段。该代码成功地创建了两个列,并将我想要的任何信息放入其中。有没有办法在开始创建/编辑表格之前将文本添加到 doc 文件的顶部?

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.Style = "No Spacing"
Set objRange = objDoc.Range()
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries


'I want to add text here above the two tables below.  Not sure how to do it.


'Create Tables
objDoc.Tables.Add objRange, 1, 2
Set objTable = objDoc.Tables(1)

'** Logo table **
objTable.Cell(1, 1).select
'Put Logo information here

'** User table **
objTable.Cell(1, 2).select
'Put User information here

objSelection.EndKey 6  'Command to end the above tables
4

1 回答 1

0

我通过使用此处找到的脚本偶然发现了这个问题:http: //blogs.technet.com/b/heyscriptingguy/archive/2006/06/09/how-can-i-add-multiple-tables-to-a -word-document.aspx

'Create Tables
Set objRange = objSelection.Range 'Adding this line fixed the problem
objDoc.Tables.Add objRange, 1, 2
Set objTable = objDoc.Tables(1)
于 2012-10-24T11:33:47.893 回答