(Merci D.bugger pour le lien)
- Code : Tout sélectionner
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim oWord As Variant
Dim sName As String
Dim iNumrows As Integer
Dim iNumcols As Integer
iNumrows = 6
iNumcols = 2
sName = "Myfile"
Set db=session.CurrentDatabase
Set dc=db.UnprocessedDocuments
If dc.Count>0 Then
Set oWord = CreateObject("Word.Application")
oWord.Application.Visible = True
oWord.documents.Add
oWord.documents(1).Activate
oWord.Selection.TypeParagraph
Call oWord.documents(1).Tables.Add(oWord.Selection.Range,1,1)
Call oWord.Activedocument.Tables(1).Cell(1,1).Range.InsertBefore("TEST")
Call oWord.Activedocument.Tables(1).Columns(1).Select()
oWord.Selection.ParagraphFormat.Alignment=1
With oWord.Selection.Font
.NameFarEast = "標楷體"
.Size = 16
.Bold = True
.Color = 255
End With
oWord.Activedocument.Tables(1).Shading.BackgroundPatternColor=16763904
Call oWord.Selection.Select()
Call oWord.Selection.EndKey(6)
oWord.Selection.TypeParagraph
For i=1 To dc.Count
Set doc=dc.GetNthDocument(i)
Call oWord.documents(1).Tables.Add(oWord.Selection.Range,iNumrows,iNumcols)
Call oWord.Activedocument.Tables(i+1).Columns(1).Select()
oWord.Selection.ParagraphFormat.Alignment=1
Call oWord.Selection.Select()
Call oWord.Activedocument.Tables(i+1).Cell(1,1).Range.InsertBefore("TEST1")
Call oWord.Activedocument.Tables(i+1).Cell(2,1).Range.InsertBefore("TEST2")
Call oWord.Activedocument.Tables(i+1).Cell(3,1).Range.InsertBefore("TEST3")
Call oWord.Activedocument.Tables(i+1).Cell(4,1).Range.InsertBefore("TEST4")
Call oWord.Activedocument.Tables(i+1).Cell(5,1).Range.InsertBefore("TEST5")
Call oWord.Activedocument.Tables(i+1).Cell(6,1).Range.InsertBefore("TEST6")
Call oWord.Activedocument.Tables(i+1).Cell(1,2).Range.InsertBefore(doc.cust_no(0))
Call oWord.Activedocument.Tables(i+1).Cell(2,2).Range.InsertBefore(doc.cust_name(0))
Call oWord.Activedocument.Tables(i+1).Cell(3,2).Range.InsertBefore(doc.cust_tel(0))
Call oWord.Activedocument.Tables(i+1).Cell(4,2).Range.InsertBefore(doc.cust_fax(0))
Call oWord.Activedocument.Tables(i+1).Cell(5,2).Range.InsertBefore(doc.cust_addr(0))
Call oWord.Activedocument.Tables(i+1).Cell(6,2).Range.InsertBefore(doc.cust_note(0))
Call oWord.Activedocument.Tables(i+1).Columns(1).SetWidth(75,1)
oWord.Activedocument.Tables(i+1).Columns(1).Shading.BackgroundPatternColor=10079487
Call oWord.Activedocument.Tables(i+1).Columns(2).SetWidth(263,1)
oWord.Activedocument.Tables(i+1).Columns(2).Shading.BackgroundPatternColor=16777164
Call oWord.Activedocument.Tables(i+1).Select()
oWord.Selection.Rows.Alignment=1
oWord.Selection.Cells.VerticalAlignment=1
Call oWord.Selection.Select()
Call oWord.Selection.EndKey(6)
oWord.Selection.TypeParagraph
Call oWord.Selection.Select()
Next
'oWord.documents(1).SaveAs "C:\temp\" & sName & ".doc"
End If