【IT168 技术文章】
1.定义word template: 这里指的template,本身还是word document,只是在打印时用作模版,生成相应的(多个)文档.
*. 定义“书签”:点击“插入”-〉“书签”。
“书签”是 Word文档中的域,与Notes form中定义的域一样的作用,通过程序(Lotus Script)把值赋给相应的书签,在Word文档中就相当于填写了相应的内容。
*.在word文档中插入书签: 。
首先打开word ,点击“插入”-〉“书签”, 打开当前word文档中定义的书签. 如要添加书签,需要把鼠标首先移动到word文档相应的位置,再点击 “插入“-> ”书签“,在“书签名字“一栏输入名字,再点击"添加",相应的书签就添加到文档上了。
*. 察看Word文档中定义的书签:点击“插入”-〉“书签”,选中要查看的书签名字,点击”定位”.你将看到你是在那定义的书签,如果像修改定义的书签,要先删除,再添加.
上传了一个已经定义好书签的word文档,大家可以参考.
2. 使用lotus script 把Notes document中的值传到word 文档中,注意的是,在保存的使用要保存成另外的名字,保持原来的 word文档是”干净的”.
下面的script可以嵌在action,button,中使用.
Sub printWordPO ( reqDoc As NotesDocument )
' reqDoc is the Notes document ready to be printed.
‘reqDoc是要打印的 notes文档的名字.
On Error Goto ErrorHandler
Dim db As NotesDatabase
Dim filename As String
Dim pathname As String
Dim fileExt As String
Dim wordPODoc As String
Dim view As NotesView
Dim dc As NotesDocumentCollection
Dim rti As NotesRichTextItem
Dim WordDoc As Variant
Dim wdFormatDocument As Variant
Dim WordObj As Variant
Dim fldName As String
Dim fldValue As String
Dim errMsg$
Set session = New NotesSession
Set db = session.CurrentDatabase
'Path to Word document template with bookmarks.
‘定义word 文档的位置.
pathName = "c:\WO\"
filename = "WO"
fileExt = ".doc" ' Active Word, open html and save as .doc
Set WordObj = CreateObject("Word.Application.8")
WordObj.Documents.Open pathname$ & fileName & fileExt
Set WordDoc = WordObj.ActiveDocument
WordDoc.Application.Visible=False
' loop through Company fields, make bookmark changes, and replace booksmarks in word doc
Call SetBookmark ( WordDoc , "AssignTo" , reqdoc.AssignTo(0) )
Call SetBookmark ( WordDoc , "WOType" , reqdoc.WOType(0) )
Call SetBookmark ( WordDoc , "Supervisor" , reqdoc.Supervisor(0) )
Call SetBookmark ( WordDoc , "SSDate" , reqdoc.SSDate(0) )
Call SetBookmark ( WordDoc , "Frequency" , reqdoc.Frequency(0) )
Call SetBookmark ( WordDoc , "TaskInstruction" , reqdoc.TaskInstruction(0) )
Call SetBookmark ( WordDoc , "Title" , reqdoc.Title(0) )
Call SetBookmark ( WordDoc , "WorkOrderNum" , reqdoc.WorkOrderNum(0) )
Call SetBookmark ( WordDoc , "PrintDate" , reqdoc.PrintDate(0) )