Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with OLE Container vs TWordApplication

114 views
Skip to first unread message

Dan Gaskin

unread,
Apr 5, 2002, 7:01:11 AM4/5/02
to
I have written a program that stores word docs in a database and allows for
retrieval and editing. I am using the OLE Container for word to facilitate
better control. My problem is that when I try to retrieve built-in and
custom document properties they are not there. The same code used with a
TWordApplication object works fine. Can anyone help?

OleContainer1.CreateObjectFromFile(myFileName, False);
OleContainer1.Modified := False;
OleContainer1.Run;
OleContainer1.BringToFront;
OleContainer1.Visible := True;
OleContainer1.DoVerb(ovPrimary);
...
...
Props :=
FOleContainer.OleObject.Application.ActiveDocument.BuiltInDocumentProperties
;
edtTitle.Text := Props.Item[wdPropertyTitle].Value;
edtSubject.Text := Props.Item[wdPropertySubject].Value;
edtAuthor.Text := Props.Item[wdPropertyAuthor].Value;
edtManager.Text := Props.Item[wdPropertyManager].Value;
edtCompany.Text := Props.Item[wdPropertyCompany].Value;
edtCategory.Text := Props.Item[wdPropertyCategory].Value;
edtKeywords.Text := Props.Item[wdPropertyKeywords].Value;
mnoComments.Text := Props.Item[wdPropertyComments].Value;

The code above does not retrieve the properties nor does it get an error.
When Props is initialized from a TWordApplication, the same code works.

Props := WordApp.ActiveDocument.BuiltInDocumentProperties;

Thanks

Dan Gaskin


Deborah Pate (TeamB)

unread,
Apr 5, 2002, 7:41:56 AM4/5/02
to
<<Dan Gaskin:
Props :=
FOleContainer.OleObject.Application.ActiveDocument.BuiltInD
ocumentProperties
>>

Don't use the ActiveDocument property with an OleContainer.
The OleContainer.OleObject /is/ the document in question.

var
Doc: OleVariant;
..
Doc := OleContainer1.OleObject;
edtTitle.Text :=
Doc.BuiltInDocumentProperties[wdPropertyTitle].Value;
edtSubject.Text :=
Doc.BuiltInDocumentProperties[wdPropertySubject].Value;

--
Deborah Pate (TeamB) http://delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html


0 new messages