none
Programmatically set the ribbon dropdown's value using Accessibility interface RRS feed

Answers

  • Which dropdown? built-in dropdown or custom dropdown?


    with regards, Yuri

    Monday, June 17, 2013 1:28 PM
  • Of course you can.

    http://msdn.microsoft.com/en-us/library/office/ff821026.aspx

    Set myRange = ActiveDocument.Paragraphs(2).Range 
    If myRange.Font.Name = "Times New Roman" Then 
     myRange.Font.Name = "Arial" 
    Else 
     myRange.Font.Name = "Times New Roman" 
    End If
    See the macro above.
    Suppose you now put your cursor in paragraph 2, and currently you've set the font to "Times New Roman". Before you run the macro, you'll have "Times New Roman" shown in the font name dropdown. Run the macro, you'll have "Arial" there.

    with regards, Yuri

    Saturday, June 22, 2013 5:13 AM
  • Hi BalaG

    Mmm, there may be some misunderstanding involved here...

    These controls reflect the state of the current selection. You can't set them to a "default value" you'd like to present to the user for convenience.

    Yuri's macro actively changes the font of the second paragraph in the document. The macro code works only for the font of a Word paragraph.

    If you want to change a Shape's background fill color then you need to use a macro that works with that Shape object. But the control in the RIbbon will only reflect the color you want when that Shape is selected.

    If you want to provide controls with a "default" suggestion then you'll have to make your own controls, not use the ones Microsoft provides.


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, June 22, 2013 10:22 AM
    Moderator

All replies

  • Which dropdown? built-in dropdown or custom dropdown?


    with regards, Yuri

    Monday, June 17, 2013 1:28 PM
  • The built-in dropdown.

    for eg: Font Name dropdown in the Home Ribbon tab

    Tuesday, June 18, 2013 7:49 AM
  • Of course you can.

    http://msdn.microsoft.com/en-us/library/office/ff821026.aspx

    Set myRange = ActiveDocument.Paragraphs(2).Range 
    If myRange.Font.Name = "Times New Roman" Then 
     myRange.Font.Name = "Arial" 
    Else 
     myRange.Font.Name = "Times New Roman" 
    End If
    See the macro above.
    Suppose you now put your cursor in paragraph 2, and currently you've set the font to "Times New Roman". Before you run the macro, you'll have "Times New Roman" shown in the font name dropdown. Run the macro, you'll have "Arial" there.

    with regards, Yuri

    Saturday, June 22, 2013 5:13 AM
  • Hi Yuri,

    Thanks for your suggestion. Can we do the same thing for a shape background fill color?

    i.e the "Shape Fill" control in the Home Tab?

    I tried setting it the same way but it didnt work!


    • Edited by BalaG M Saturday, June 22, 2013 7:30 AM missed a line
    Saturday, June 22, 2013 7:26 AM
  • Hi BalaG

    Mmm, there may be some misunderstanding involved here...

    These controls reflect the state of the current selection. You can't set them to a "default value" you'd like to present to the user for convenience.

    Yuri's macro actively changes the font of the second paragraph in the document. The macro code works only for the font of a Word paragraph.

    If you want to change a Shape's background fill color then you need to use a macro that works with that Shape object. But the control in the RIbbon will only reflect the color you want when that Shape is selected.

    If you want to provide controls with a "default" suggestion then you'll have to make your own controls, not use the ones Microsoft provides.


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, June 22, 2013 10:22 AM
    Moderator