OleAuto, Word 8, Number of pages in document

Delphi 2, OleAuto, Word 8, Number of pages in document

How can I read the number of pages in the active document of Word 97?

I am using Delphi Developer version 2.
My program is working as an Ole-Automation client with MS Word 97 working as
the Ole-Automation server.
Things are running perfect as long as I only call methods.
This is illustrated in the following code:

unit MyUnit;
uses OLEAuto;
var    W : Variant;


function MyFunction
var
  NumPages : word;
  WordVersion : string;
begin
  try
    W := GetActiveOleObject('Word.Application');
  except
    W := CreateOleObject('Word.Application');
  end;
  WordVersion := W.Application.Version; {get the version number}
 
  {other code}
 
  {The next line doesnt work:}
  NumPages := W.ActiveDocument.BuiltInDocumentProperties
(wdPropertyPages)
end;

The last code line does not work. It generates an exception
BuiltInDocumentProperties is not a method. It seems that I can only use
methods and that properties cannot be read.
Can someone explain me how I can read the number of pages of the active Word
document into my Delphi application?
Alfred Hoks
alh...@worldonline.nl