I'm working on a legacy Delphi 6 (Build 6.240, Update Pack 2) application that works fine on Windows XP and Office 2000 - 2003.
Our client now wants to be able to run the app on Windows 7 with Office 2010.
The code seems to still create the Word merged document successfully, and saves it to a BLOB field in the Oracle database, and can successfully re-open the document from the database in Word 2010.
The problem is that the application then needs to create a PDF version of the document (using PDF-XChange), so it uses OleContainer.SaveAsDocument
to write the document to a temporary file on disk. Attempting to open this document in Word 2010 (or even Word 2003) displays a "File Conversion" dialog box to "select the encoding that makes your document readable". None of the options seem to make the document readable (and even if they did there would still be a problem as this is an automated process).
The OleConnection
is established using CreateObject('Word.document.8', false)
I have also tried other values instead of 8 - 9, 10, 11 and 14 cause an 'invalid class string' error while 12 or just 'Word.document' run but have the same effect as 8, ie the saved document cannot be opened in Word.
So, the question is - how can I save a Word document from an OleContainer
in Delphi 6, on Windows 7 with Word 2010, in a format that can be re-opened by Word?