Link to home
Start Free TrialLog in
Avatar of robert_marquardt
robert_marquardt

asked on

for each to Word with COM

I have implemented a Word AddIn in Delphi which uses the COM interface of Word 97.
What i miss is the "for each" loop of VBA to access all the elements of a list even when the index is string not integer. Some lists of Word cannot be enumerated with integers.
I suspect the undocumented property _NewEnum (from the imported OLB) to provide the access.
Has anyone explored this property and its usage?
I think this is a "feature" to force the programmers to use VBA even with COM interfaces.
Avatar of RBertora
RBertora
Flag of United Kingdom of Great Britain and Northern Ireland image

say list name is "Dem"

use

for lp := 0 to Dem.count-1
begin
  Myvariable := Dem(lp);
end;

that generally works,
can you give me a specific example you are thinking of

Rob;-)
Avatar of robert_marquardt
robert_marquardt

ASKER

Bookmarks are indexed with their names.
So its BookmarkList.Items('Name of Bookmark')
Some of these lists cannot be indexed by numbers or they have noncontigous indices and throw an exception on nonexistant elements. Even with a message box on Word side.
ASKER CERTIFIED SOLUTION
Avatar of vladika
vladika

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial