Visual Studio Developer Center >
Visual Studio Forums
>
Visual Studio Tools for Office
>
Screen coordinates of a Ribbon control
Screen coordinates of a Ribbon control
- Does anybody know how to get the screen coordinates of a Ribbon control. for example the coordinates of the Adress book button.
Answers
- 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.
- Ribbon Accessibility
- Tony Jollans article: http://wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.htm
- Blog article on which that bases: http://blogs.msdn.com/pranavwagh/archive/2008/01/21/how-to-switch-ribbon-tab-programmatically-looks-simple.aspx
- MSDN documentation: http://msdn.microsoft.com/en-us/library/bb404170.aspx
Cindy Meister, VSTO/Word MVP- Marked As Answer byBessie ZhaoMSFT, ModeratorWednesday, November 11, 2009 10:01 AM
- Ribbon Accessibility
- 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- Marked As Answer byBessie ZhaoMSFT, ModeratorWednesday, November 11, 2009 10:01 AM
All Replies
- 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. - 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.
- Ribbon Accessibility
- Tony Jollans article: http://wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.htm
- Blog article on which that bases: http://blogs.msdn.com/pranavwagh/archive/2008/01/21/how-to-switch-ribbon-tab-programmatically-looks-simple.aspx
- MSDN documentation: http://msdn.microsoft.com/en-us/library/bb404170.aspx
Cindy Meister, VSTO/Word MVP- Marked As Answer byBessie ZhaoMSFT, ModeratorWednesday, November 11, 2009 10:01 AM
- Ribbon Accessibility
- 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- Marked As Answer byBessie ZhaoMSFT, ModeratorWednesday, November 11, 2009 10:01 AM
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.


