Board index » delphi » MSWord97 OLE & VB Collections

MSWord97 OLE & VB Collections

Hi,
I have any problem with Delphi2 and MsWord 97.
When I want to use VB collection (array of objects),
I got error.
Here is my code:

var
MSWord: Variant;
begin
MSWord:=CreateOleObject('Word.Application');
MSWord.visible := true;
MSWord.documents.add('ks.dot');
MSWord.ActiveDocument.Bookmarks('COMPANY').Select;
// Error:"bookmarks" is not method
MSWord.ActiveDocument.Bookmarks['COMPANY'].Select;
// Error:"item" (?) is not property
end;

And here is example from Microsoft Word Visual Basic HelpFile:
ActiveDocument.Bookmarks("temp").Select

File 'ks.dot' exists and bookmark 'COMPANY' is defined.

Please, do you have some suggestion?

Thanx.
Leos

 

Re:MSWord97 OLE & VB Collections


Delphi 2, OLE Word97
I answer myself :-)), direct way doesn't work, need to use 'item':

MSWord.ActiveDocument.Bookmarks.Item('COMPANY').Select;
It works.

Quote
>MSWord.ActiveDocument.Bookmarks('COMPANY').Select;

It doesn't work.

Leos

Other Threads