Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Does anyone of you know how to loop over all groups using a macro?
Normally I would count the items in the array I've got through "getgroups" and do a "for...next...loop" over them, but somehow I can't figure out how to count the existing groups (cyclic and drilldown) in the document.The normal count-method doesn't seem to work here.
Thanks for your help in advance...
Hi
a bit strange, also ubound/lbound do not work. maybe better solutions exist than this one
sub groupmembers()
grouparray=activedocument.getgroups
for i = 0 to 5
on error resume next
set gp=grouparray(i).GetProperties
if err <> 0 then
msgbox("err " & i)
exit for
end if
next
end sub
Regards
Jürg
you could use a while not isnull statement instead of for...next
try this one:
-> gives you groups and containing fields
Sub Get_Groups()
groups = ActiveDocument.GetGroups
j=0
For each item in groups
set gp = groups(j).GetProperties
set gd = groups(j).GetDescription
set vars = gp.FieldDefs
for i = 0 to vars.Count-1
set fld = vars.Item(i)
msgbox("Group: " & gd.Name & " - field " & i+1 & " is " & fld.Name)
Next
j=j+1
next
End Sub