2 Replies Latest reply: Dec 3, 2012 3:00 AM by Christopher Murrell RSS

    Macro Create Container Error

    Christopher Murrell

      Hello,

       

      I hope someone can help, I am trying to create a new container object and assign some objects into it.

      The below code I have copied directly out of the QV11 API and it just wont work. I have updated the 2 object ID's to 2 List Boxes I have on my page but when I run it the edit module window opens. The container itself is create but not the objects are not put in place.

       

      Set ContainerObj = ActiveDocument.Sheets("Main").CreateContainer

      set ContProp=ContainerObj.GetProperties

      ContProp.ContainedObjects.Add

      ContProp.SingleObjectMode=1

      ContProp.SingleObjectStyle=1

      ContProp.ShowObjectTypeIcons=true

      ContProp.ContainedObjects.Add

      ContProp.ContainedObjects.Item(0).Id = "Document\LB06"

      ContProp.ContainedObjects.Item(0).Text.v = "Test1"

      ContProp.ContainedObjects.Add

      ContProp.ContainedObjects.Item(1).Id = "Document\LB05"

      ContProp.ContainedObjects.Item(1).Text.v = "Test2"

      ContainerObj.SetProperties ContProp

        • Re: Macro Create Container Error
          mayilvahanan ramasamy

          HI

           

          Try like this

           

          Sub Test

          Set ContainerObj = ActiveDocument.Sheets("Main").CreateContainer

          set ContProp=ContainerObj.GetProperties

          ContProp.ContainedObjects.Add

          ContProp.SingleObjectMode=1

          ContProp.SingleObjectStyle=1

          ContProp.ShowObjectTypeIcons=true

          ContProp.ContainedObjects.Add

          ContProp.ContainedObjects.Item(0).Def.ObjectId= "Document\LB11"

          ContProp.ContainedObjects.Item(0).Text.v = "Test1"

          ContProp.ContainedObjects.Add

          ContProp.ContainedObjects.Item(1).Def.ObjectId = "Document\LB10"

          ContProp.ContainedObjects.Item(1).Text.v = "Test2"

          ContainerObj.SetProperties ContProp

           

          End sub

           

          hope it helps