
Need Help with Word Automation
Hi Fabien,
To avoid having to set another range, you could add the following statements
immediately before your PrintDocument statement. These statements position
the insertion point at the start of the document and then insert a note
before the table.
WA.Selection.HomeKey wdStory
WA.Selection.SplitTable
WA.Selection.InsertBefore "this is a note"
Make sure you position these statements AFTER the statement that creates the
table.
Bill Coan
Fill out letters, contracts, forms, in seconds! DataPrompter
prompts you for data, inserts it, updates it automatically.
Details at http://www.wordsite.com/DataPrompter.html
Quote:
Quote:
> Hello,
> I am using Word Automation to make a table with the information I have in
my
> VB program.
> I use the following function to do it.
> However I would like to include some notes at the beginning of the table
to
> describe the table's content.
> When I try to do so, it works but the text generated is overwritten by the
> table.
> I suppose I have to create another "Range" object but I dont know how to
do
> it.
> Please help!
> Public Sub PrintTable(titles As String, align As Variant, titre As String,
> Optional oRS As ADODB.Recordset, Optional infos As String)
> On Error Resume Next
> Dim oDoc As Word.Document
> Dim oRange As Word.Range
> Dim sTemp As String
> Dim sFileName As String
> Set oDoc = WA.Documents.Add
> WA.Selection.Font.Name = "Arial"
> WA.Selection.Font.Size = 10
> Set oRange = oDoc.Range
> oRange.ParagraphFormat.Alignment = wdAlignParagraphRight
> If (IsMissing(infos) = True) Then
> sTemp = oRS.GetString(adClipString, -1, vbTab)
> Else
> sTemp = infos
> End If
> sTemp = titles & vbCrLf & sTemp
> oRange.Text = sTemp
> oRange.ConvertToTable vbTab, , , , wdTableFormatList4, AutoFit:=
> IncludePageNbr
Selection.HomeKey wdStory
Selection.SplitTable
Selection.InsertBefore "this is a test"
Quote:
> PrintDocument
> CloseDocument
> End Sub