Set wordDoc = wordApp.Documents.open(FilePath) '<建立Word Document物件>
Set myDocSelection = wordApp.Selection.Document.Content 'myDocSelection is Range object
Call myDocSelection.Find.Execute(FindText,False,True,False,False,False,True,1,False,ReplaceText,2)
PDFPath = Strleft(FilePath,".doc") & ".PDF"
wordApp.ActiveDocument.SaveAs2 PDFPath, 17
wordApp.Quit(False)
Kill PDFPath
Dim session As New NotesSession
Dim ws As New NotesUIWorkSpace
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim itemDoc As NotesDocument
Dim FilePath As String
Dim sdc As NotesDocumentCollection
Dim X As Integer
Dim Y As Integer
Set db=session.CurrentDatabase
Set doc=ws.CurrentDocument.Document
FilePath=CreateTmpDir()
qstr="Form=""fWordTemp"""
Set sdc=db.Search(qstr,Nothing,0)
If sdc.Count=0 Then
Msgbox "請先建立好 Word 範本檔 !",48,"錯誤"
Exit Sub
End If
Set WordDoc=sdc.GetFirstDocument
Set rtitem=WordDoc.GetFirstItem("File")
Forall o In rtitem.EmbeddedObjects
FileName=o.Source
FilePath=FilePath & o.Source
Call o.ExtractFile(FilePath)
Exit Forall
End Forall
On Error Goto ErrHandle '// 例外處理
Set wordApp = CreateObject("Word.Application") '<建立Word Application物件>
Set wordDoc = wordApp.Documents.open(FilePath) '<建立Word Document物件>
Set myDocSelection = wordApp.Selection.Document.Content 'myDocSelection is Range object
Set wordSelect1 = wordApp.Selection
'wordApp.visible=True
'// 表頭
X = 2
Y = 1
Call wordSelect1.MoveDown(5,6) '向下移 line 6
Call wordSelect1.EndKey(5)
'Call wordSelect1.TypeText(doc.GetItemValue("SORTING_HOUSE")(0))
Set myTable = wordApp.ActiveDocument.Tables(1)
Call myTable.rows(2).Cells(2).Range.InsertAfter(doc.RequesterCName(0))
Call myTable.rows(2).Cells(4).Range.InsertAfter(doc.instanceos(0))
Call myTable.rows(3).Cells(2).Range.InsertAfter(doc.vendor(0)) '廠商
Dim dateTime As New NotesDateTime(doc.RMA_DATE(0))
'Call myTable.rows(3).Cells(4).Range.InsertAfter(dateTime.DateOnly) 'RMA日期
Call myTable.rows(3).Cells(4).Range.InsertAfter(doc.OrderNo(0)) '訂單編號
Call myTable.rows(4).Cells(2).Range.InsertAfter(doc.name(0)) '品名
Call myTable.rows(4).Cells(4).Range.InsertAfter(doc.DateList(0)) '日期
Call myTable.rows(5).Cells(2).Range.InsertAfter(doc.PN(0)) ' 料號
Call myTable.rows(5).Cells(4).Range.InsertAfter(doc.Factory(0)) ' 廠別
If doc.Content(0) <> "" Then
Set myTable = wordApp.ActiveDocument.Tables(2)
Call myTable.rows(2).Cells(1).Range.InsertAfter(doc.Content(0)) ' 2nd table
End If
'// 細項
'Set myTable = wordApp.ActiveDocument.Tables(2) '// 指定要插入列的是哪一個Table,1表示第一個Table
wordApp.Activedocument.saveas(FilePath)
Call wordDoc.PrintOut(0)
wordApp.quit
Msgbox "已經列印 RMA REPORT ( " & doc.RMA_NO(0) & " ) 完畢 !",32,"完成"
If CheckFile(FilePath) Then
Kill FilePath
End If
Exit Sub
沒有留言:
張貼留言