My second time request for help under the same title. And I have put all togher everyting that I have collected on the first posting.
I am NOT a professional at VB6 BUT I am willing to listen and follow any ideas.
Please be patient.
The error I received is "Object variable or With block variable not set".
Please advice.
Thanks.
[vba]
Option Explicit
Dim Tbl As Table
Dim objApp As Word.Application
Private Sub Form_Load()
With objApp
.Selection.Font.Bold = True
.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Selection.TypeText Text:="How are you"
.Selection.TypeText Text:=vbCrLf
.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
End With
Set Tbl = ActiveDocument.Tables.Add(Range:=Selection.Range, _
NumRows:=4, NumColumns:=2)
Tbl.Range.Font.Bold = True
Tbl.Columns(1).Width = 20
Tbl.Cell(1, 1).Range.Text = "AAA"
Tbl.Cell(1, 2).Range.Text = "111"
Tbl.Cell(2, 1).Range.Text = "BBB"
Tbl.Cell(2, 2).Range.Text = "222"
Tbl.Cell(3, 1).Range.Text = "CCC"
Tbl.Cell(3, 2).Range.Text = "333"
Tbl.Cell(4, 1).Range.Text = "DDD"
Tbl.Cell(4, 2).Range.Text = "444"
With objApp
.Selection.Font.Bold = True
.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Selection.TypeText Text:=vbCrLf
.Selection.TypeText Text:="Thank you!"
End With
objApp.ActiveDocument.SaveAs FileName:="c:\test\test1.doc"
Set objApp = Nothing
End Sub
[/vba]