When I run the code with the .visible property set to .T. and Word runs in the foreground everything works fine but with the .visible property set to .F. I get the following error when it gets to the last line of code shown below:
"OLE IDispatch exception code 0 from Microsoft Word: The requested member of the collection does not exist..."
Between the creation of the table and the selection of it I have entered data into cells and done some formatting via VFP commands.
I am using VFP 7 and Word 2000. Any ideas what the fix is? I don't have the option of going to a newer copy of Word either.
Thanks,
Chad
"OLE IDispatch exception code 0 from Microsoft Word: The requested member of the collection does not exist..."
Between the creation of the table and the selection of it I have entered data into cells and done some formatting via VFP commands.
I am using VFP 7 and Word 2000. Any ideas what the fix is? I don't have the option of going to a newer copy of Word either.
Thanks,
Chad
Code:
*-- Create the OLE object in WinWord
oWord = CREATEOBJECT('Word.Application')
*-- Base the new document on the NORMAL template
oWord.Documents.Add
*-- Display WinWord's application window so we can see what is happening.
WITH oWord
.ActiveWindow.View.Type = 3
.Selection.Homekey(6)
.Visible = .F.
.ActiveWindow.ActivePane.View.ShowAll = 0
.Selection.Font.Name = "Times New Toman"
.Selection.Font.Size = 12
ENDWITH
<snip>
*-- Construct Project Development expenditures table
owRange = oWord.Selection.Range
oWord.Activedocument.Tables.Add(owRange, 4, ln_numcols)
oTable = oWord.ActiveDocument.Tables(1)
<snip>
oWord.Selection.Tables(1).Select