Hi guys, I need to learn how to create a MS-Word Table using the language VB6.
This is all I could do so far:
I'd like to know if this is the best way to create the table. Also I'd like to know how to set the column Width, borders and colors and how may I change the space between cells ?
Thanks
This is all I could do so far:
Code:
Private Sub Command1_Click()
Dim Word_App As Word.Application
Dim Word_Doc As Word.Document
Dim Word_Table As Word.Table
Dim Word_Range As Word.Range
Dim iCount As Integer
Set Word_App = New Word.Application
Set Word_Doc = Word_App.Documents.Add(DocumentType:=wdNewBlankDocument)
Set Word_Table = Word_Doc.Tables.Add(Word_App.Selection.Range, 3, 5)
Set Word_Range = Word_App.ActiveDocument.Content
Set Word_Doc = Word_App.ActiveDocument
Set Word_Table = Word_Doc.Tables.Add(Range:=Word_Doc.Range(Start:=0, End:=0), NumRows:=2, NumColumns:=2)
iCount = 1
Word_Doc.Tables(1).AutoFitBehavior (wdAutoFitContent)
For Each Cell In Word_Table.Range.Cells
Cell.Range.InsertAfter "Hello World " & iCount
iCount = iCount + 1
Next Cell
Word_Doc.SaveAs FileName:="C:\p\Test"
Word_Doc.Close False
Word_App.Quit False
End Sub
Thanks
Comment