2010年12月23日 星期四

[Lotus script]-Word 出出出

'將Notes資料輸出並套用至Word範本檔裡面
1.首先建立一個Word的範本檔
使用「插入」、「功能變數」設定欄位作為資料儲存體

使用「插入」、「書籤」設定書籤作為插入位置

2.NOTES表單中對應匯出程式如下:

Sub WordOutOutOut( M_To As String, M_DY As String, M_DM As String, M_DD As String, M_NO As String, M_SP As String, M_SEC As String,M_AH As String,M_Sub As String,M_Body As String,M_MAIN As String,M_BEND As String)
    Dim session As New NotesSession
    Set db=session.CurrentDatabase
    Set wdoc=session.DocumentContext   
   
    DefDocPath="C:\missive_out_sample.dot" '設定路徑
   
    Set oWord = CreateObject("Word.Application")
    oWord.Application.Visible = True
    oWord.documents.Add DefDocPath, False
    Set WordDoc = oWord.activedocument
    '=======Go to bookmark=======
    WordDoc.Bookmarks("TO").Select
    Call oWord.Selection.TypeText(M_To)
    WordDoc.Bookmarks("YY").Select
    Call oWord.Selection.TypeText(M_DY)
    WordDoc.Bookmarks("MM").Select
    Call oWord.Selection.TypeText(M_DM)
    WordDoc.Bookmarks("DD").Select
    Call oWord.Selection.TypeText(M_DD)
    WordDoc.Bookmarks("NO").Select
    Call oWord.Selection.TypeText(M_NO)
    WordDoc.Bookmarks("SPEED").Select
    Call oWord.Selection.TypeText(M_SP)
    WordDoc.Bookmarks("SECURE").Select
    Call oWord.Selection.TypeText(M_SEC)
    WordDoc.Bookmarks("ATTACH").Select
    Call oWord.Selection.TypeText(M_AH)
    WordDoc.Bookmarks("SUBJECT").Select
    Call oWord.Selection.TypeText(M_Sub)
    WordDoc.Bookmarks("BODY").Select
    Call oWord.Selection.TypeText(M_BODY)
    WordDoc.Bookmarks("MAIN").Select
    Call oWord.Selection.TypeText(M_MAIN)
    WordDoc.Bookmarks("BEND").Select
    Call oWord.Selection.TypeText(M_BEND)
   
    ''==========================
    'oWord.documents(1).SaveAs "c:\Tmp\WM20101223.doc"
End Sub

--
看到、想到、說到、做到 
能夠填平大海的誓言,也比不上邁出一步的價值 
是以吾輩此生,再無任何誓言

沒有留言: