none
Showing linked file names in the Word 2010 Ribbon RRS feed

  • Question

  • I have created my own Tab and groups in the Ribbon as below

    screen shot of customised ribbon

    I have lots of links in my document to external files, like Excel, and would love to be able to place the names of the linked files in My Own Tab, for quick access. A drop-down box would be a space save if they could be put into one, otherwise just the names displayed would still work. Thanks, Mary

    Thursday, April 5, 2012 2:19 AM

Answers

  • Hi Maxy2012,

    Thank you for posting.

    Your requirement can be achieved, please refer to the following code snippet, I created a document level Add-In and add three links to the document, I added the Ribbon Designer item and write code for the Ribbon1.cs :

    using Microsoft.Office.Tools.Ribbon;
    using Microsoft.Office.Interop.Word;
     
    namespace WordDocRibbonAddItems
    {
        public partial class Ribbon1
        {
            private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
            {
     
                foreach (Hyperlink link in Globals.ThisDocument.Hyperlinks)
                {
                    RibbonDropDownItem item
        = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                    item.Label = link.Range.Text;
                    this.dropDown1.Items.Add(item);
                }
            }
        }
    }

    Screenshot after running:

    Hope this can help you and just feel free to follow up after you have tried.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Bruce Song Thursday, April 26, 2012 10:00 AM
    Monday, April 9, 2012 7:59 AM

All replies

  • Hi Maxy2012,

    Thank you for posting.

    Your requirement can be achieved, please refer to the following code snippet, I created a document level Add-In and add three links to the document, I added the Ribbon Designer item and write code for the Ribbon1.cs :

    using Microsoft.Office.Tools.Ribbon;
    using Microsoft.Office.Interop.Word;
     
    namespace WordDocRibbonAddItems
    {
        public partial class Ribbon1
        {
            private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
            {
     
                foreach (Hyperlink link in Globals.ThisDocument.Hyperlinks)
                {
                    RibbonDropDownItem item
        = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
                    item.Label = link.Range.Text;
                    this.dropDown1.Items.Add(item);
                }
            }
        }
    }

    Screenshot after running:

    Hope this can help you and just feel free to follow up after you have tried.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Bruce Song Thursday, April 26, 2012 10:00 AM
    Monday, April 9, 2012 7:59 AM
  • Have you considered simply adding the 'Edit Links' option to the QAT.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Monday, April 9, 2012 10:14 PM
  • Hi Paul

    Thank you so much for your time and for you reply.  I actually have the Edit Links in my Tab, and its fine, but not the quick shortcut of actually seeing the Hyperlinks, either in a drop-down or list, section in the Tab.

    regards

    Mary

    Wednesday, April 18, 2012 5:07 AM
  • Hi Bruce

    Thank you for answering my query.  I tried to make what you gave me into a macro but this does not work.  I think I need to start at the beginning and create a Document Level Addin, but I do not know how to do this.  I tried to get notes on Google but they do not make sense.  Do you think you could help me with simple instructions, or direct me to somewhere that they have easy to follow instructions.  Also do I have to work outside of MS Word 2010 or can this be done from inside the program.

    The screen grab of your Addin Tab and Item list is exactly what I need, unfortunately, I don't have enough expertise to get my Ribbon to look like yours.

    My sincere thanks

    Mary Fay  --  mfay101cc@gmail.com

    Thursday, April 19, 2012 3:40 AM
  • Mary Fay, I uploaded the demo to my skydrive:

    https://skydrive.live.com/?cid=C7D080162E80A07A&id=C7D080162E80A07A%21115

    named WordDocRibbonAddItems. Hope this can help you.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, April 26, 2012 10:00 AM