Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
I have to create 6 cycle groups for a large multi-way table. The need to contain the same 40 variables in the same order. Is there a way to copy one cycle group to make the others, rather than having to make them all manually, it's a bit of a pain!
Thanks.
You can use macro for that:
Sub CopyGroup (SrcName, DstName) Set SrcGrp = ActiveDocument.GetGroup(SrcName) Set SrcProps = SrcGrp.GetProperties Set DstGrp = ActiveDocument.CreateGroup(DstName) Set DstProps = DstGrp.GetProperties DstProps.FieldDefs.CopyFrom SrcProps.FieldDefs DstProps.IsCyclic = SrcProps.IsCyclic DstProps.Labels = SrcProps.Labels DstProps.Present = SrcProps.Present DstProps.SortCriterias.CopyFrom SrcProps.SortCriterias DstGrp.SetProperties DstProps End Sub
Calling:
Sub DoCopying CopyGroup "ExistingGroupName", "NewGroupName" End Sub
Cheers
Darius
You can use macro for that:
Sub CopyGroup (SrcName, DstName) Set SrcGrp = ActiveDocument.GetGroup(SrcName) Set SrcProps = SrcGrp.GetProperties Set DstGrp = ActiveDocument.CreateGroup(DstName) Set DstProps = DstGrp.GetProperties DstProps.FieldDefs.CopyFrom SrcProps.FieldDefs DstProps.IsCyclic = SrcProps.IsCyclic DstProps.Labels = SrcProps.Labels DstProps.Present = SrcProps.Present DstProps.SortCriterias.CopyFrom SrcProps.SortCriterias DstGrp.SetProperties DstProps End Sub
Calling:
Sub DoCopying CopyGroup "ExistingGroupName", "NewGroupName" End Sub
Cheers
Darius
This is very useful. Thanks Darius!
Exteremely useful!
New version of the script. If destination group exists, it replaces it's contents.
Sub CopyGroup (SrcName, DstName)
Set SrcGrp = ActiveDocument.GetGroup(SrcName)
Set SrcProps = SrcGrp.GetProperties
Set DstGrp = ActiveDocument.GetGroup(DstName)
If DstGrp Is Nothing Then
Set DstGrp = ActiveDocument.CreateGroup(DstName)
Else
Set DstProps = DstGrp.GetProperties
for i = 1 to DstProps.FieldDefs.Count
DstGrp.RemoveField 0
Next
End If
Set DstProps = DstGrp.GetProperties
DstProps.FieldDefs.CopyFrom SrcProps.FieldDefs
DstProps.IsCyclic = SrcProps.IsCyclic
DstProps.Labels = SrcProps.Labels
DstProps.Present = SrcProps.Present
DstProps.SortCriterias.CopyFrom SrcProps.SortCriterias
DstGrp.SetProperties DstProps
End Sub
' Calling
Sub DoCopying
CopyGroup "grp1", "grp2"
End Sub
Cheers Darius
Hi Darius,
This was so useful I registered just to say thank you. Thank You!
Excellent solution Darius,
you make me gain a lot of time!
Thank you!
N.