Add a Cube Group Example

This macro adds a cube group to an existing model using the 'Sales region' dimension as the basis for the group. One child cube in the group is not created.
Sub Example4()
    Dim objTransApp As Object
    Dim objModel As Object
    Dim objDimRegion As Object
    Dim objCubesByRegion As Object
    Dim strCategoryCode As String
    Dim objChildCube As Object
    Dim strIBMCognos10Location As String
    Dim strModelPath As String
    Dim strModelSource As String
    'Change these paths to match your installation
    strIBMCognos10Location = "C:\Program Files\IBM\Cognos\c10\"
    strModelSource = "great outdoors sales.mdl"
   strModelPath = strIBMCognos10Location & _
        "webcontent\samples\models\Transformer8\EN\" & strModelSource
    objTransApp = CreateObject("IBMCognosTransformer.ApplicationCtrl.1")
    With objTransApp
        .DataSourcePath = strIBMCognos10Location & "bin"
        .TransdaPath = strIBMCognos10Location & "CS7Gateways\bin\TransDa.exe"
    End With
    objModel = objTransApp.OpenModel(strModelPath)
    objDimRegion = objModel.Dimensions("Sales region")
    objCubesByRegion = objModel.Cubes.Add(xtrObjectType.trCubeGroup)
    With objCubesByRegion
        'Specify the category levels on which to base the cubes
in the group.
        .GroupDimension = objDimRegion
        .GroupLevel = objDimRegion.DrillDowns(1).Levels("Sales region")
        'Specify the level of detail and summary level.
        .DetailLevel = objDimRegion.DrillDowns(1).Levels("Country")
        .SummaryLevel = objDimRegion.DrillDowns(1).Levels("Sales
region")
        .Name = "Regions"
        .MDCFile = ""
        .CubeCreation = xtrCubeCreation.trCubeCreationON
        .Optimize = xtrCubeOptimize.trOptimizeDefault
        .CompressMDC = False
        .CacheCrossTabs = False
        .MeasureInclude(objModel.Measures("Unit cost")) = False
        .MeasureName = "Revenue Made"
        .Update()
    End With
    'Name each cube in the group after its category name 
    For index = 1 To objCubesByRegion.GroupLevel.CategoryCount
        strCategoryCode = objCubesByRegion.GroupLevel.LevelCategories(index).Code
        objChildCube = objCubesByRegion.ChildCubes(strCategoryCode)
        With objChildCube
            .Name = objCubesByRegion.GroupLevel.LevelCategories(index).Name
            .Update()
        End With
    Next
    'Do not generate a child cube for Central Europe.
    objChildCube = objCubesByRegion.ChildCubes("Central Europe")
    With objChildCube
        .CubeCreation = xtrCubeCreation.trCubeCreationOFF
        .Update()
    End With
    'Generate the cubes (this may take a few minutes)
    objCubesByRegion.CreateMDCFile()
    With objModel
        .SaveAs("great outdoors salesX.mdl")
        .Close()
    End With
    objChildCube = Nothing
    objDimRegion = Nothing
    objCubesByRegion = Nothing
    objModel = Nothing
    objTransApp = Nothing
End Sub