Click here to Skip to main content
13,053,026 members (61,733 online)
Rate this:
Please Sign up or sign in to vote.
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.
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 27-Mar-13 23:48pm
Updated 27-Mar-13 23:51pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to reference to the cell/range, which you want to use later:
In pseudocode:
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
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.

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.
Maciej Los 28-Mar-13 7:47am
What kind of replacement???
If you want my help, please,be more specific and provide more details...

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100