Dim objWord As Word.Application
Dim rst As Recordset
Dim strSQL As String
' Launch Word and load the invoice template
Set objWord = New Word.Application
objWord.Documents.Add _
Application.CurrentProject.Path & "\CMA.dot"
objWord.Visible = True
' Add header information using predefined bookmarks
''''''' With objWord.ActiveDocument.Bookmarks
''''''' .Item("OrderID").Range.Text = frmOrder.OrderID
''''''' .Item("OrderDate").Range.Text = frmOrder.OrderDate
''''''' End With
' Get details from database and create a table
' in the document
Set rst = New Recordset
rst.Open strSQL, CurrentProject.Connection
With CreateTableFromRecordset(objWord.ActiveDocument.Bookmarks("RPPRdata").Range, rst, True)
' Add rows for subtotal, freight, total
With .Rows.Add
.Cells(1).Range.Text = "Average"
.Cells(4).Range.Text = FormatNumber(frmRpprDataSelected.AvgSalePrice, 0)
.Cells(3).Range.Text = FormatNumber(frmRpprDataSelected.AvgListPrice, 0)
.Cells(7).Range.Text = FormatNumber(frmRpprDataSelected.AvgListDays, 0)
' Fix up paragraph alignment
.Range.ParagraphFormat.Alignment = wdAlignParagraphRight
.Columns(1).Select
objWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
objWord.Selection.MoveDown
End With
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.