Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys !! I started to wonder that, if we usually import / export variables to avoid an extra work. What about groups of dimensions?? It would be great to do the same with them.
Don't you think???
Hi Again,
Here you go...
Sub Import_DimensionGroups()
Groups=ActiveDocument.GetGroups
Groups(0).AddField "Age"
set gp = groups(0).GetProperties
gp.IsCyclic = false
Groups(0).SetProperties gp
End Sub
________________________________________________________________________________________
In the above code you are using two classes :
1. Group
2. IGroupProperties
________________________________________________________________________________________
Using the Group Class you are adding the new field to the group. Please see the relevant code to this class.
Groups=ActiveDocument.GetGroups
Groups(0).AddField "Age"
Groups(0) is the first Dimension Group and you can access the other groups by changing the index number - Example : Groups(1).
.AddField is the method and in the above example I am adding "Age" - which is a static field name. However, you can add a dynamic field or/and a bookmark.
________________________________________________________________________________________
You can also change the type of the Dimension Group. i,e. you can use the IsCyclic property to set it to the relevant Group. If this property is true then you will have a Cyclic Group and If this is false then you will have Drilldown Group. Below is the code for the same :
set gp = Groups(0).GetProperties
gp.IsCyclic = false
Groups(0).SetProperties gp
________________________________________________________________________________________
I hope this makes sense. Please let me know if you need further help.
Cheers - DV
Hi,
You can use the below code to get the groups.
Sub Get_DimensionGroups()
groups = ActiveDocument.GetGroups
set gp = groups(0).GetProperties
set vars = gp.FieldDefs
for i = 0 to vars.Count-1
set fld = vars.Item(i)
msgbox("field " & i+1 & " is " & fld.Name)
Next
End Sub
You can add the same to variables to access the groups. I hope this helps!
Cheers - DV
Yeah that's great DV. And how do you import it as a group?
Hi Again,
Here you go...
Sub Import_DimensionGroups()
Groups=ActiveDocument.GetGroups
Groups(0).AddField "Age"
set gp = groups(0).GetProperties
gp.IsCyclic = false
Groups(0).SetProperties gp
End Sub
________________________________________________________________________________________
In the above code you are using two classes :
1. Group
2. IGroupProperties
________________________________________________________________________________________
Using the Group Class you are adding the new field to the group. Please see the relevant code to this class.
Groups=ActiveDocument.GetGroups
Groups(0).AddField "Age"
Groups(0) is the first Dimension Group and you can access the other groups by changing the index number - Example : Groups(1).
.AddField is the method and in the above example I am adding "Age" - which is a static field name. However, you can add a dynamic field or/and a bookmark.
________________________________________________________________________________________
You can also change the type of the Dimension Group. i,e. you can use the IsCyclic property to set it to the relevant Group. If this property is true then you will have a Cyclic Group and If this is false then you will have Drilldown Group. Below is the code for the same :
set gp = Groups(0).GetProperties
gp.IsCyclic = false
Groups(0).SetProperties gp
________________________________________________________________________________________
I hope this makes sense. Please let me know if you need further help.
Cheers - DV
Many thanks DV I think this is all I need to do my experiments.
See you around!!