Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi TechGurus,

I have overwritten the Excel and doing multiple manipulations based the selected object.
I am getting the correct selected object by using the application.selection property
object selectedObj = _xlApp.ActiveWindow.Selection;
and based on the selected object I am checking if the selected object is not a Range object then call the default windowProc so that Excel can handle those messages.
C#
if (!(selectedObj is MsExcel.Range))
{
      base.WndProc(ref msg);
      handled = true;
}

But, due to instruction: object selectedObj = _xlApp.ActiveWindow.Selection;
I am not able to resize the size of comment window in Excel.

Please suggest some other method through which i can get the selected object.

Thanks in Advance.

- virenk
Posted
Updated 27-Mar-13 23:51pm
v2

1 solution

You need to reference to the cell/range, which you want to use later:
In pseudocode:
C++
Excel.Workbook Wbk = _xlApp.Workbooks.Open("fullfilename")
Excel.Worksheet Wsh = Wbk.Worksheets(index)
Excel.Range Rng = Wsh.Range("A1")

if (Rng.Value2 == 5)
{
     //do something
}
 
Share this answer
 
Comments
Virendra_ec10 28-Mar-13 6:20am    
Hi Maciej Los,

Thanks for your quick reply.
I need to know if the current selected object is not a Range object(For example if the current selected object is comment box) then call the default windproc.
Can you please help to get the current selected object without using the selection property.

Thanks,
virenk
Maciej Los 28-Mar-13 6:30am    
I'm not sure what you mean... Please, explain what you are trying to achieve and share your code. What is a comment box?
Virendra_ec10 28-Mar-13 6:43am    
In Excel Right Click on any cell->select "Insert comment" from the option menu it opens comment box. I don't want to override any message that comes from the resizing or editing of comment box. So, I am trying to handle like this:
object selectedObj = _xlApp.ActiveWindow.Selection;//problamatic line want to replace with some other method

if (!(selectedObj is MsExcel.Range))
{
base.WndProc(ref msg);
handled = true;
}
Maciej Los 28-Mar-13 6:47am    
Still i don't get what you are trying to achieve...
Virendra_ec10 28-Mar-13 7:43am    
I just want replacement of _xlApp.ActiveWindow.Selection.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900