Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Table in Word from Access

Status
Not open for further replies.

TimTDP

Technical User
Feb 15, 2004
373
ZA
, and need help with the syntax for the following:

1. change the font size of the entire table
2. change the width of colums
3. make the text in an entire row bold

Many thanks
 
Oops, my copy and paste did note work!

Post should read:

I am creating a mail merge that inserts a table into Word 2000 from Access 2000, and need help with the syntax for the following:

1. change the font size of the entire table
2. change the width of colums
3. make the text in an entire row bold

Many thanks
 
Could you post what code you have already?

Gerry
 
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

' Build SQL string for details
strSQL = "SELECT [Address]," & _
"[Erf No]," & _
"[List Price]," & _
"[Sale Price]," & _
"[RPPRStandM2]," & _
"[RPPRResM2]," & _
"[Days On Market]," & _
"[RPPRPercentDrop]" & _
"FROM [qryRPPRDataForCMA]"

' 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)

End With

.Range.Font.Size = 8

'Set width works nicely!
.Range.Tables(1).Columns(2).SetWidth CentimetersToPoints(3), wdAdjustNone
.Range.Tables(1).Columns(2).Select
objWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter



'Other alternative
'.AutoFormat


' Apply formatting
'.AutoFormat wdTableFormatProfessional
'.AutoFitBehavior wdAutoFitContent

' Fix up paragraph alignment
.Range.ParagraphFormat.Alignment = wdAlignParagraphRight
.Columns(1).Select
objWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
objWord.Selection.MoveDown
End With

' We're done
Set objWord = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top