General information
Category:
Coding, syntax & commands
Title:
OLE automation with MS-Word
In order to print a huge report I have created a link with Word.
When starting the print I notice some strange behaviour within the document that is being created.
If Word is visible everything works like a charm. However, I don't want to bore my user with Word flashing in front of his eyes so I decided to created the report in the background.
This is when things get vague. When creating tables and leaving them things work fine as long as Word is visible. If Word is not visible the creation of the matrix goes wrong.
Where is my routine going wrong???
Can anyone please help.
Ron Brahma
*********************************************
testObject = CREATEOBJECT("Word.Application")
* the dot-file is only used as a template use something else (if you want to...
testObject.documents.add('c:\temp\test.dot')
testObject.visible= .T.
=to_word()
testObject.selection.typetext('You should not be in the matrix' + chr(13))
testObject.visible= .F.
=to_word()
testObject.selection.typetext('You should not be in the matrix' + chr(13))
testObject.visible= .T.
return
procedure to_word
testObject.activedocument.tables.add(testObject.selection.range, 1, 2)
testObject.selection.typetext(alltrim('This is the first column'))
testObject.selection.MoveRight(12) &&wdCell
testObject.selection.typetext(alltrim('This is the second column'))
if testObject.selection.cells.count > 0
* Make sure you are NOT inside the table
testObject.selection.movedown(5, 1) &&wdLine, count
endif
* leave the matrix
testObject.selection.movedown(5, 1) &&wdLine, count
RETURN
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only