Page 1 of 1 1
Topic Options
#77452 - 2001-04-03 06:09 PM for each...next with a colection
d.adams Offline
Fresh Scripter

Registered: 2000-12-07
Posts: 41
Loc: Eagle Rock, VA, USA
Just playing around here, but I can't get the For Each loop in the code below to work.

There is no error message. The $wd.Templates.Count prints 6, which is correct. It just won't print the name of the 6 templates.

Any ideas? Thanks in advance.

code:

break on

$wd = CreateObject("Word.Application")

? $wd.Templates.Count

For Each $template In $wd.Templates
? $template.Name
Next

sleep 5

$wd.quit(0)

exit



Top
#77453 - 2001-04-03 06:31 PM Re: for each...next with a colection
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
d.

Remember when Ruud mentioned that COM/OLE was not fully finished yet. I've heard that this is the part that's not (fully) done yet (multi-level references)...

In the meantime, this is the way I've worked around it...

code:

break on


$wd = CreateObject("Word.Application")


? $wd.Templates.Count ; <--- this one works (nice)


$Templates = $wd.Templates ; <--- workaround


For Each $Template In $Templates
? $Template.Name
Next


?"pause..." gets $k


$wd.quit(0)


exit


Shawn.

[This message has been edited by Shawn (edited 03 April 2001).]

Top
#77454 - 2001-04-04 01:59 PM Re: for each...next with a colection
d.adams Offline
Fresh Scripter

Registered: 2000-12-07
Posts: 41
Loc: Eagle Rock, VA, USA
Thanks Shawn! That worked. I really appreciate the help and I hope the final version of Kix2001 will fix this multi-level object access.
Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 640 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.053 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.