Board index » delphi » delphi ole winword bookmarks

delphi ole winword bookmarks

Does anybody know why the following Statement causes an error

var
  OApp : Variant;
begin
  OApp := GetActiveOleObject('Word.Application.8');
  ShowMessage(OApp.ActiveDocument.Bookmarks.Count);
// Returns correct "15"
  ShowMessage(OApp.ActiveDocument.Bookmarks[1].Name);
// causes Error "Item is no property"
in VB I tested
  MsgBox ActiveDocument.Bookmarks.Item(1).Name
and this returns the first Bookmark-Name

I tried also
  ShowMessage(OApp.ActiveDocument.Bookmarks(1).Name);
It causes Error "Bookmarks is no method" - that seems me to be ok.

thanks for any help
Dietmar

 

Re:delphi ole winword bookmarks


Try the following :

 ActiveDocument.Bookmarks.Item(1).Name
(just like you did in VB)

This works fine in my code.
--
Bert Vermeiren
Email : Bert.Vermei...@eds.com

Dietmar Brueckmann <brueckm...@kzvth.ef.uunet.de> wrote in article
<36542C72.46922...@kzvth.ef.uunet.de>...

Quote
> Does anybody know why the following Statement causes an error

> var
>   OApp : Variant;
> begin
>   OApp := GetActiveOleObject('Word.Application.8');
>   ShowMessage(OApp.ActiveDocument.Bookmarks.Count);
> // Returns correct "15"
>   ShowMessage(OApp.ActiveDocument.Bookmarks[1].Name);
> // causes Error "Item is no property"
> in VB I tested
>   MsgBox ActiveDocument.Bookmarks.Item(1).Name
> and this returns the first Bookmark-Name

> I tried also
>   ShowMessage(OApp.ActiveDocument.Bookmarks(1).Name);
> It causes Error "Bookmarks is no method" - that seems me to be ok.

> thanks for any help
> Dietmar

Other Threads