通过Domino COM实现Web的痕迹保留设..
时间:2010-09-07 来源:pstn2008
实现步骤:
1,客户端注册NOTES COM控件。(regsvr32 c:\lotus\notes\DOMOBJ.TLB)regsvr32 c:\lotus\notes\nlsxbe.dll
2,在公文数据库中,保存一些已经定制好的公文模板。已供新建公文时使用。
3,表单上加入VBScript将附件从服务器拆离到本地,然后起用WORD。(Word的宏安全性设为中)
4,公文模板中,WORD的文档的退出事件中加入VBA代码,实现文件上传到服务器。
注:为避免启动COM时出现提示口令输入框,可以通过API制作一个DLL来避开。(参考:API例子的)
相关代码:
表单上的VBScript代码:
<SCRIPT LANGUAGE=”VBScript”>
Sub Button1_OnClick
dim s, dir, db, doc, eo, no, word, worddoc
Set s = CreateObject(”Lotus.NotesSession”)
Call s.Initialize
Set db = s.GetDatabase(”sh_server”,”intranet\webtemp.nsf”)
Set doc = db.getDocumentByUNID(”30C11B03D279463548256C7D000DDD74″)
Set eo = doc.getAttachment(”普通公文.doc”)
Call eo.ExtractFile( “C:\Temp\test.doc”)
‘Create the Word object:
Set word = CreateObject(”Word.Application”) ‘Create Word object
Call word.documents.open( “C:\Temp\test.doc” )
Set worddoc = word.activedocument ‘Get a handle for the active document
word.visible = True
‘Call eo.remove
‘Set ritem = doc.getFirstItem(”rtfAttachment”)
‘Set no = ritem.EmbedObject(1454, “” , “C:\Temp\test.doc” )
‘Call doc.save(True,False)
‘MsgBox db.filename + ” & ” + db.server,, “Databases on ” + db.server
End Sub
</SCRIPT>
表单上的按钮代码:
<INPUT NAME=”Button1″ TYPE=”BUTTON” VALUE=”编辑正文”>
Word模板上的VBA代码:
Private Sub Document_Close()
ActiveDocument.Save
Dim s, dir, db, doc, eo, no, word, worddoc
Set s = CreateObject(”Lotus.NotesSession”)
Call s.Initialize
Set db = s.GetDatabase(”sh_server”, “intranet\webtemp.nsf”)
Set doc = db.GetDocumentByUNID(”C47E90193C0E4D3248256C780006A73E”)
Set eo = doc.GetAttachment(”普通公文.doc”)
Call eo.Remove
Set ritem = doc.GetFirstItem(”rtfAttachment”)
Set no = ritem.EmbedObject(1454, “”, “C:\Temp\test.doc”)
Call doc.Save(True, False)
MsgBox db.FileName + ” 文件已上传至服务器!& ” + db.Server, , “Databases on ” + db.Server
End Sub