WordApp CustomDocumentProperties

Add-in Express™ Support Service
That's what is more important than anything else

WordApp CustomDocumentProperties
How to read and write document properties in word 
Fran59


Guest


Hello,

I try to read and write document properties in word,
but I can not compile in Delphi ,

I have a syntax error , but I don't find the good syntax. Can someone help me ?

Here my code,


var 
  ASubject : string;
begin
  ASubject := WordApp.ActiveDocument.CustomDocumentProperties(wdPropertySubject).Value;
end;


Thanks very much in advance for your help
Regards,
Fran?ois
Posted 12 Jul, 2012 18:13:18 Top
Fran59


Guest


Hello,

I finally solve it :
I hope it could help someone in the future, here the solution I found.
First thing, I had to use 'BuiltInDocumentProperties' instead 'CustomDocumentProperties'.
In fact the problem is the 'BuiltInDocumentProperties' is an 'IDispatch', so I solve it using an OleVariant.
And I add to use '[' instead of '('.
(finally, I sleep some hours , perhaps it helps too ;-) )


var
 ASubject : string;
 ADoc : oleVariant;
begin
 ADoc := WordApp.ActiveDocument;
 ASubject := ADoc.BuiltInDocumentProperties[wdPropertySubject].Value;
end;
Posted 13 Jul, 2012 02:33:48 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello,

Thank you for posting this. You are right, CustomDocumentProperties and BuiltInDocumentProperties collections contain different sets of properties and you use one or anothe depending on your business logic.


Andrei Smolin
Add-in Express Team Leader
Posted 13 Jul, 2012 06:26:57 Top