流星小筑
火流星一闪即逝,只留给人们许下心愿的瞬间

导航

 

 

实现步骤:

1,客户端注册NOTES COM控件。(regsvr32 c:\lotus\notes\DOMOBJ.TLB)regsvr32  c:\lotus\notes\nlsxbe.dll

(笔者注:注册domino 的com组件是用的nlsxbe.dll,而不是domobj.tlb.这个让我郁闷了半天.)

2,在公文数据库中,保存一些已经定制好的公文模板。已供新建公文时使用。

3,表单上加入VBScript将附件从服务器拆离到本地,然后起用WORD。(Word的宏安全性设为中)

4,公文模板中,WORD的文档的退出事件中加入VBA代码,实现文件上传到服务器。 (笔者注:见过某个公司的OA是写的关闭时自动保存.)

 

注:为避免启动COM时出现提示口令输入框,可以通过API制作一个DLL来避开。(笔者注:就是用c api做一个domino的登陆验证filter)

 

相关代码:

表单上的VBScript代码:

  1. <SCRIPT LANGUAGE="VBScript">
  2. Sub Button1_OnClick
  3.     dim s, dir, db, doc, eo, no, word, worddoc
  4.     Set s = CreateObject("Lotus.NotesSession")
  5.     Call s.Initialize
  6.     Set db = s.GetDatabase("sh_server","intranet\webtemp.nsf")
  7.     Set doc = db.getDocumentByUNID("30C11B03D279463548256C7D000DDD74")
  8.     Set eo = doc.getAttachment("普通公文.doc")
  9.     Call eo.ExtractFile( "C:\Temp\test.doc")
  10.   'Create the Word object:
  11.   Set word = CreateObject("Word.Application") 'Create Word object
  12.   Call word.documents.open( "C:\Temp\test.doc" ) 
  13.   Set worddoc = word.activedocument 'Get a handle for the active document
  14.   word.visible = True
  15.     'Call eo.remove
  16.     'Set ritem = doc.getFirstItem("rtfAttachment")
  17.     'Set no = ritem.EmbedObject(1454, "" , "C:\Temp\test.doc" )
  18.     'Call doc.save(True,False)administrator
  19.     ad
  20.     'MsgBox db.filename + " & " + db.server,, "Databases on " + db.server
  21. End Sub
  22. </SCRIPT>

表单上的按钮代码:

  1. <INPUT NAME="Button1" TYPE="BUTTON" VALUE="编辑正文">

Word模板上的VBA代码:

  1. Private Sub Document_Close()
  2.     ActiveDocument.Save
  3.     Dim s, dir, db, doc, eo, no, word, worddoc
  4.     Set s = CreateObject("Lotus.NotesSession")
  5.     Call s.Initialize
  6.     Set db = s.GetDatabase("sh_server""intranet\webtemp.nsf")
  7.     Set doc = db.GetDocumentByUNID("C47E90193C0E4D3248256C780006A73E")
  8.     Set eo = doc.GetAttachment("普通公文.doc")
  9.     Call eo.Remove
  10.     Set ritem = doc.GetFirstItem("rtfAttachment")
  11.     Set no = ritem.EmbedObject(1454, """C:\Temp\test.doc")
  12.     Call doc.Save(True, False)
  13.     MsgBox db.FileName + " 文件已上传至服务器!& " + db.Server, , "Databases on " + db.Server
  14. End Sub

上述内容还少了一个步骤,用js创建文件流将服务器上的文件下载到客户端本地。

posted on 2008-11-24 11:52  风渐寒pro  阅读(541)  评论(0编辑  收藏  举报