none
Find Control Id for 'Zoom', '100%', 'Zoom To Selection' in Excel RRS feed

  • Question

  • HI,

    I am looking to get control instances of 'Zoom', '100%', 'Zoom To Selection' which can be found under View menu in Excel 2010's Command bar. I just want to add an event-handler to these controls so that I can log whenever user clicks this control. I am stuck on this for a while. Any help would be much appreciated.

    Thanks.

    Tuesday, April 12, 2011 8:49 AM

All replies

  • Hi,

    I am trying to just log whenever a user hits 'Zoom to selection' in Excel 2010 under view Menu. I got hold of two Zoom controls with IDs 1733 and 925. One is of type CommandControlComboBox and other is of type CommandControlButton. The code is below:

    Office.CommandBarComboBox z1 = (Office.CommandBarComboBox)this.Application.CommandBars.FindControl(Office.MsoControlType.msoControlComboBox, 1733, missing, true);
    z1.Change += new Office._CommandBarComboBoxEvents_ChangeEventHandler(this.z1_Change);
    Office.CommandBarButton z2 = (Office.CommandBarButton)this.Application.CommandBars.FindControl(missing, 925, missing, missing);
    z2.Click += new Office._CommandBarButtonEvents_ClickEventHandler(z2_Click);

    Inside the event handler, I have just a line which logs the button.Caption in some file but the new event-handlers are never get fired when I click 'Zoom', '100%', or 'Zoom to Selection' button. What am I missing here?

    Thanks.

    Thursday, March 10, 2011 8:51 AM
  • Hi pacific08,

    Thanks for posting in the MSDN Forum.

    Do you ensure that you get the correct instance? Please check it via some actions such as change its caption or background.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, March 14, 2011 8:45 AM
    Moderator
  • Hi Tom,

    Thanks for the reply! I think you are right I may not have correct instance, nothing happened when I changed the caption text. I am specifically looking for adding even handlers for controls -- 'Zoom', '100%', 'Zoom To Selection' which can be found under View menu in Excel 2010's Command bar. I am stuck on this for almost a week, I would really appreciate it if you can give me some idea on how to do this.

    Thanks.

    Thursday, March 17, 2011 5:09 AM
  • Hi pacific08,

    I've looked through your new problem and it's not directly related to the original issue. Thus it would be best if you open up a new thread for the new question. In this way, our discussion here will not deviate too much from the original issue. This will make answer searching in the forum easier and be beneficial to other community members as well.

    Thank you for your understanding.


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, April 12, 2011 7:45 AM
    Moderator
  • HI,

    I am looking to get control instances of 'Zoom', '100%', 'Zoom To Selection' which can be found under View menu in Excel 2010's Command bar. I just want to add an event-handler to these controls so that I can log whenever user clicks this control. I am stuck on this for a while. Any help would be much appreciated.


    Hi pacific

    Excel 2010 no longer uses the CommandBar for commands; it uses the RIbbon. Some of the old Control IDs might continue to work - for a while. But that's not guaranteed. You can try asking in the Excel for Developers forum (http://social.msdn.microsoft.com/Forums/en-US/exceldev/threads) whether any of the application specialists know what these are, and whether they still work as part of the CommandBars object model...

    But you really should migrate to the Ribbon if you want to handle excel's internal commands (or be notified). There are no "events", as such, for controls in the Ribbon that have no control ID. You have to re-purpose those commands.


    Cindy Meister, VSTO/Word MVP
    Tuesday, April 12, 2011 9:05 AM
    Moderator