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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Over riding autoformat

Status
Not open for further replies.

BusMgr

IS-IT--Management
Aug 21, 2001
138
US
I have an Access form that I output a word document from with a command button. I have a table on the document that is made up of three rows currently. The autoformat is set to wdTableFormatContemporary, which bolds the cells that are defined as headings. When I add a row that is headings, I want to format the text as bold, but the auto format overrides any code.

The code is as follows:

' Build SQL string for details
strSQL = "SELECT [Footage Drilled], [Footage Reamed], [Footage Cement], " & _
"[Pumping Time], [Drilling Time], [Rotary Time], [Sliding Time], [Avg RPM], [DHM], [Avg GPM] FROM [qryMech] " & _
"WHERE BitSN = 'BW392'"

' 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("Details").Range, rst, True)


'Add row for AvgROP, RotaryTurns, Sliding/Pumping, TotalRevs
With .Rows.Add
.Cells(1).Range.Text = "Avg ROP (ft/hr)"
.Cells(2).Range.Text = "Rotary Turns"
.Cells(3).Range.Text = "Sliding/Pumping"
.Cells(4).Range.Text = "Total Number of Revs"
End With
With .Rows.Add
.Cells(1).Range.Text = FormatNumber((frmMain.FtgDrill / frmMain.TimeDrill), 2)
.Cells(2).Range.Text = FormatNumber((frmMain.TimeRot * 60 * frmMain.AvgRPM), 1)
.Cells(3).Range.Text = FormatNumber((frmMain.TimePump * 60 * frmMain.AvgGPM * frmMain.DHM), 1)
.Cells(4).Range.Text = FormatNumber((frmMain.TimeRot * 60 * frmMain.AvgRPM) + (frmMain.TimePump * 60 * frmMain.AvgGPM * frmMain.DHM), 1)
End With

' Apply formatting
.AutoFormat wdTableFormatContemporary
.AutoFitBehavior wdAutoFitContent

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

Any help is appreciated.

BusMgr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top