I have a Delphi ActiveX that called from a macro on a Word template. It manages documents and opens them in the word instance.
In part of it I use another hidden word instance to generate text previews of the documents to be shown before opening.
TBlobField(fieldbyname( cdocumentDatafield)).SaveToFile(tmpDocPath +HTMLDOCPREVIEWFILE);
DMMain.WordApphtml.documents.Open(tmpDocPath +HTMLDOCPREVIEWFILE);
DMMain.WordApphtml.activedocument.Saveas(tmpDocPath +HTMLPREVIEWFILE, wdFormatText);
DMMain.WordApphtml.activedocument.Close;
The variable is created like this
dmmain.Wordapphtml := CreateOleObject('Word.Application');
dmmain.WordApphtml.Visible := false;
Basically the code dumps the file from the database, opens the file in my hidden word instance and saves it as a text file which I can then load.
My problem is that after the text file is generated and I load it, my application has lost focus (its still displayed on top of word, but if I hit a key nothing happens). I assume the invisible app now has focus