I'm using VFP9 and trying to do a mail merge on the fly in Word. I have a Word document with some basic formatting (bold, etc).
I can open the document and I store oRange.TEXT to a variable but when I try to reinsert the text, the formatting is lost.
I use this code to get the original text:
Then I open Word, add a new document and use this code to setup the new document:
The text from the original document appears in the new document, but all the formatting is removed. All the text appears as normal.
I wondered if I could try opening the original document, copying the text then pasting it into the new document. This is my first foray into Automation, so my knowledge isn't that great.
Thanks in advance,
Neil
I can open the document and I store oRange.TEXT to a variable but when I try to reinsert the text, the formatting is lost.
I use this code to get the original text:
Code:
oDocument = GETOBJECT(cDocument)
oRange = oDocument.RANGE()
cOriginal = oRange.TEXT
Then I open Word, add a new document and use this code to setup the new document:
Code:
oWord = CreateObject("Word.Application")
oDocument = oWord.Documents.ADD()
SELECT tempdata
SCAN
oRange = oDocument.RANGE()
oRange.TEXT = oRange.TEXT + cOriginal
...
ENDSCAN
The text from the original document appears in the new document, but all the formatting is removed. All the text appears as normal.
I wondered if I could try opening the original document, copying the text then pasting it into the new document. This is my first foray into Automation, so my knowledge isn't that great.
Thanks in advance,
Neil