hi i have a c# program which creates a ribbon on excel-2007, on that ribbon i have two buttons one for zoom in and other for zoom out.
my question is how is it possible so that when i press one of the above buttons and then select the cell or range on a sheet that cell or range will be zoomed in or out?
my problem is i do not know how to assign event for those two buttons?
private void ws_selCh1(Excel.Range Target)
{
MessageBox.Show(
"Zoom Out:" +
Target.get_Address(mis, mis,
Excel.XlReferenceStyle.xlA1, mis, mis)
);
}
private void ws_selCh2(Excel.Range Target)
{
MessageBox.Show(
"Zoom In:" +
Target.get_Address(mis, mis,
Excel.XlReferenceStyle.xlA1, mis, mis)
);
}
private void button1_Click(object sender, RibbonControlEventArgs e)
{
ws = Globals.ThisAddIn.GetActiveWorksheet();
ws.SelectionChange +=
new Excel.DocEvents_SelectionChangeEventHandler(
ws_selCh1
);
}
private void button2_Click(object sender, RibbonControlEventArgs e)
{
ws = Globals.ThisAddIn.GetActiveWorksheet();
ws.SelectionChange +=
new Excel.DocEvents_SelectionChangeEventHandler(
ws_selCh2
);
}
currently i was trying to sense the range or cell being selected (but it creates me problem): when i click the second button it displays both messages in ws_selCh1 and ws_selCh2 which i don't want... then, of course, after handling this issue i wanted to add the following ...
ws.Application.ActiveWindow.Zoom = 23;
which would increase and decrease it... whenever the appropriate button is clicked and cell +range is selected.
am i on the right way? if no, can you suggest me a better way? also how is it possible that the selected range will be active visible range for the user?
many thanks!