Thread: word table
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika Dick Kusleika is offline
external usenet poster
 
Posts: 179
Default word table

v

Here's an example. Set a reference (VBE - Tools - References) to the
Microsoft Word x.x Object Library.

Sub maketable()

Dim wd As Word.Application
Dim wdDoc As Word.Document
Dim i As Long
Dim j As Long

Set wd = New Word.Application
Set wdDoc = wd.Documents.Add

wd.Visible = True

wdDoc.Tables.Add wd.Selection.Range, _
Selection.Rows.Count, Selection.Columns.Count

With wdDoc.Tables(1)
For i = 1 To .Rows.Count
For j = 1 To .Columns.Count
.Cell(i, j).Range.Text = _
Selection.Cells(i, j).Value
Next j
Next i
End With

End Sub
"v." wrote in message
...
I should write a VBA code that creates a table in a Word
sheet. This table has to contain values coming from an
Excel sheet.....help me please!!