You are here: Scripting Techniques > Common Script Operations > Creating topic groups in a script

Creating topic groups in a script

To create named groups, use the Add method of the Groups collection:

Groups.Add "novice"

Groups.Add "intermediate"

Groups.Add "expert"

Groups created in this manner are not associated with any topics. This is analogous to creating groups in the Index toolbar.

However, if you use the Groups collection of the active topic, and not of the project, then the groups are created and associated with the active topic:

ActiveTopic.Groups.Add "novice"

ActiveTopic.Groups.Add "intermediate"

ActiveTopic.Groups.Add "expert"

This is analogous to entering groups in the Index tab of the topic properties pane. Note that you can simplify the script and make it more efficient by assigning the Groups collection of the ActiveTopic object to a variable:

Dim grps

Set grps = ActiveTopic.Groups

grps.Add "novice"

grps.Add "intermediate"

grps.Add "expert"