mdnuts
Registered User.
- Local time
- Today, 11:30
- Joined
- May 28, 2014
- Messages
- 128
When I run this code to create a word doc - the first time no problem. Second time it pops the Error 462 error. Research on it shows it's usually when ActiveDocument is referenced without specifying the word.Application first. All that is fine I only have that in one location and it's referenced properly.
Where it is failing is the first width declaration (I copied the code up to the end of the Width settings).
and I can't figure out why - any other references to oTable.Cell or oTable.Rows do not error - just that first width declaration. (Just for additional information, each time the word document is closed before trying to generate a second time).
any ideas?
Where it is failing is the first width declaration (I copied the code up to the end of the Width settings).
Code:
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oTable As Table
Dim oRow As Word.row
Set oWord = New Word.Application
oWord.Visible = True
Set oDoc = oWord.Documents.Add
' Initiate the table
Set oTable = oDoc.Tables.Add(oDoc.Paragraphs(1).Range, 1, 5)
oTable.Borders.Enable = True
oTable.Borders.OutsideColor = wdColorGreen
oTable.Borders.InsideColor = wdColorGreen
' Set the head of the table
oTable.Cell(1, 1).Range.Text = strWhatEmployee
oTable.Cell(1, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
oTable.Cell(2, 1).Width = InchesToPoints(1.75)
oTable.Cell(2, 2).Width = InchesToPoints(0.8)
oTable.Cell(2, 3).Width = InchesToPoints(2.66)
oTable.Cell(2, 4).Width = InchesToPoints(0.66)
oTable.Cell(2, 5).Width = InchesToPoints(1)
any ideas?