Problem when addinag a RibbonLabel to the Ribbon in word 2007

Jun 7 2011 6:54 AM

Hi all,

        Currently i am working on Ms-Word 2007 Addin. Here I am using an xml file to generate the Ribbon labels dynamically. Please find the attached xml code.

<Groups>

      <LabelGroup>

        <GroupName>grpDocumentInformation</GroupName>

        <GroupLabel>Document  Information</GroupLabel>

        <Labels>

          <Label>

            <LabelName>lblReferenceNo</LabelName>

            <LabelText>Reference No:</LabelText>

          </Label>

          <Label>

            <LabelName>lblReferenceType</LabelName>

            <LabelText>Reference Type:</LabelText>

          </Label>

          <Label>

            <LabelName>lblCreatedBy</LabelName>

            <LabelText>Created By</LabelText>

          </Label>

          <Label>

            <LabelName>lblDocumentType</LabelName>

            <LabelText>Document Type:</LabelText>

          </Label>

        </Labels>

      </LabelGroup><Groups>


        I am getting this xml and my code follows like this:
       
        

XmlNodeList labelGroupsList = xmlDoc.DocumentElement.SelectNodes("//Groups/LabelGroup");

 

foreach (XmlNode group in labelGroupsList)

            {

                rGroup = new RibbonGroup();

                rGroup.Name = group.SelectSingleNode("GroupName").InnerText;

                rGroup.Label = group.SelectSingleNode("GroupLabel").InnerText;

 

                XmlNodeList labelElements = group.SelectNodes("Labels");

                foreach (XmlNode labelList in labelElements)

                {

                    XmlNodeList labels = labelList.SelectNodes("Label");

                    foreach (XmlNode label in labels)

                    {

                        rLabel = new RibbonLabel();

                        rLabel.Name = label.SelectSingleNode("LabelName").InnerText;

                        rLabel.Label = label.SelectSingleNode("LabelText").InnerText;

                        rLabel.Enabled = true;

                        rLabel.ShowLabel = true;

                        rGroup.Items.Add(rLabel);

                    }

                }

                tab1.Groups.Add(rGroup);

            }


  I am getting  problem when i am adding the Label to the Group(as indicated in green color).if  that line is commented, i will get an empty group.

  Please help me adding the label to the group.

Thanks,
K.S. Reddi Prasad.


Answers (1)