none
Problem when addinag a RibbonLabel to the group of the Ribbon in word 2007 RRS feed

  • Question

  • 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.

    tHANKS, K.S.R.Prasad.
    Tuesday, June 7, 2011 11:02 AM

Answers

  • <<  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.>>

    Why would the line be commented? Of course, if it's commented the group will be empty - that line is adding each item to the group. If it's commented out, nothing will be added and you get an empty group - all logical. So I don't understand the problem...


    Cindy Meister, VSTO/Word MVP
    • Proposed as answer by Bruce Song Tuesday, June 28, 2011 12:28 PM
    • Marked as answer by Bruce Song Thursday, July 7, 2011 12:19 PM
    Tuesday, June 7, 2011 2:22 PM
    Moderator

All replies

  • Hi,

    What problem are you getting in when you add the label into the Group? Can you explain what error/issue/exception do you get? I know that if you comment that line you will get an empty group (because no item was added).

    Regards,

    Mauro


    twitter.com/mcastagnasso | castagnasso.wordpress.com | If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Tuesday, June 7, 2011 1:10 PM
  • <<  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.>>

    Why would the line be commented? Of course, if it's commented the group will be empty - that line is adding each item to the group. If it's commented out, nothing will be added and you get an empty group - all logical. So I don't understand the problem...


    Cindy Meister, VSTO/Word MVP
    • Proposed as answer by Bruce Song Tuesday, June 28, 2011 12:28 PM
    • Marked as answer by Bruce Song Thursday, July 7, 2011 12:19 PM
    Tuesday, June 7, 2011 2:22 PM
    Moderator