2008. július 14., hétfő

Read the properties of a Word document


Problem/Question/Abstract:

I want to read the properties of a MS Word document (the title). I use the function builtInDocumentProperties, but it returns a IDispatch Interface and I don't know how to get the value. If I write Document.BuiltInProperties[wdPropertyTitle].Value, I get an error.

Answer:

Variants are the easiest way of dealing with these properties.

{ ... }
var
  Doc: OleVariant;
  { ... }
  Doc := Word.ActiveDocument;
  Doc.BuiltInDocumentProperties['Title'].Value := 'The title';
  Doc.BuiltInDocumentProperties['Category'].Value := 'Category';
  { ... }


Nincsenek megjegyzések:

Megjegyzés küldése