Ask a questionAsk a question
 

AnswerScreen coordinates of a Ribbon control

  • Thursday, November 05, 2009 1:45 PMRimidalv Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Does anybody know how to get the screen coordinates of a Ribbon control. for example the coordinates of the Adress book button.

Answers

All Replies

  • Saturday, November 07, 2009 9:56 AMBessie ZhaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello,

    I guess you means the built-in ribbon controls. Unfortunately, as Cindy said in this thread, we cannot access Ribbon controls of office applications directly by using object model. So here, I think it is not possible to get the coordinates of a Ribbon control through object model. 

    In office 2007, Ribbon is designed to allow us to add/invisible controls by using Ribbon Designer or Ribbon XML. In Ribbon XML, we could access built-in group/control using idMso value.

    Here are some resource which may interest you:
    Customizing the 2007 Office Fluent Ribbon for Developers: Part 1, Part 2, and Part 3.
    Control IDs of 2007 Office system: 2007 Office System Document: Lists of Control IDs.

    Best regards,
    Bessie

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Saturday, November 07, 2009 10:05 AMCindy MeisterMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Bessie

    One additional thought on this, that occurred to me as I read your reply (no idea why not, sooner). Unfortunately, I'm getting ready to travel again, and things are topsy-turvey here, so I can't look into it myself.

    Possibly, the Ribbon Accessibility would give some information on screen co-ordinates. I've never used it, so I don't have all the properties and capabilities "at hand", but it does offer a possibility for "selecting" a particular Ribbon tab programmatically. So maybe there's something that will let one get screen co-ordinates? Worth taking a look, anyway.

     
    Cindy Meister, VSTO/Word MVP
  • Saturday, November 07, 2009 5:12 PMTony JollansMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Yes, you can do it via the Accesibility interface. If you get a reference to an IAccessible object for the Ribbon element (see references quoted by Cindy) you are interested in - and it is Visible, then you can use .accLocation to get the co-ordinates. One point to note is that you will get Pixels and may want Points, but you can use the PixelsToPoints function to convert.
    Enjoy, Tony
  • Monday, November 09, 2009 9:25 AMBessie ZhaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello Cindy,

    Before I did not know there was such a method as you mentioned. Now I have got it. Thanks for pointing it out.

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.