i have the following code, however, the table that is created always starts at the begining of the document. so none of the text written beforehand can be seen. i also dont know how to write things after the table.
Private Sub wrd2()
Dim c As Long
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim wrdTbl As Word.Table
Dim wrdRange As Word.Range
Set wrdApp = New Word.Application
Set wrdDoc = wrdApp.Documents.Add
Set wrdRange = wrdDoc.Range(Start:=0, End:=0)
r = flxItems.Rows
c = flxItems.Cols
Set wrdTbl = wrdDoc.Tables.Add(wrdRange, r, c)
With wrdApp
.Visible = True
.ActiveDocument.SaveAs App.Path & "\invoices\" & invoiceID & ".doc"
.Selection.Font.Name = "Arial"
.Selection.Font.Size = 12
.Selection.TypeText Text:="Customer Name : " & txtCustomerName & vbNewLine
.Selection.TypeText Text:="Staff ID : " & lblStaffID & vbNewLine
.Selection.TypeText Text:="Invoice Date : " & currDate & vbNewLine
.selectionTypeText Text:="Invoice Number : " & invoiceID & vbNewLine & vbNewLine & vbNewLine
End With
If flxItems.Rows = 0 Or flxItems.Rows = 1 Then Exit Sub
r = flxItems.Rows
c = flxItems.Cols
With flxItems
For r = 1 To .Rows
For c = 1 To .Cols
wrdTbl.Cell(r, c).Range.Text = .TextMatrix(r - 1, c - 1)
Next c
Next r
End With
With wrdTbl
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
End With
wrdApp.ActiveDocument.Save
wrdApp.Quit False
End Sub
anyone willing and able to help?