![]() |
How can I detect that an excel cell has been clicked
I have a vb.net app which includes an excel sheet. I need to detect when a
cell has been clicked but there does not appear to be an appropriate event to handle. So far I have handled the "XLSheet.SelectionChange" event to achieve my requirements BUT if the cell in question is ALREADY selected, clicking on it will not raise the above event. I have to click elsewhere so that the selection changes, the result being that data is added to the worksheet in the "wrong" cell. Am I missing something that should be really obvious? I am using vb.net express (2008) and Office 2007 (interop). |
How can I detect that an excel cell has been clicked
In 2003, there is a Worksheet_SelectionChange that triggers when a cell is
selected. -- HTH, Barb Reinhardt "Ballantine" wrote: I have a vb.net app which includes an excel sheet. I need to detect when a cell has been clicked but there does not appear to be an appropriate event to handle. So far I have handled the "XLSheet.SelectionChange" event to achieve my requirements BUT if the cell in question is ALREADY selected, clicking on it will not raise the above event. I have to click elsewhere so that the selection changes, the result being that data is added to the worksheet in the "wrong" cell. Am I missing something that should be really obvious? I am using vb.net express (2008) and Office 2007 (interop). |
How can I detect that an excel cell has been clicked
Never mind. YOu've already looks at SelectionChange. From what I've seen,
it needs to be freshly selected to trigger the event. -- HTH, Barb Reinhardt "Ballantine" wrote: I have a vb.net app which includes an excel sheet. I need to detect when a cell has been clicked but there does not appear to be an appropriate event to handle. So far I have handled the "XLSheet.SelectionChange" event to achieve my requirements BUT if the cell in question is ALREADY selected, clicking on it will not raise the above event. I have to click elsewhere so that the selection changes, the result being that data is added to the worksheet in the "wrong" cell. Am I missing something that should be really obvious? I am using vb.net express (2008) and Office 2007 (interop). |
How can I detect that an excel cell has been clicked
Thanks for showing some interest and very promptly too. Unfortunately you
are only telling me what I already know. Hopefully someone else will have come across the same issue and will tell us how they overcame it. "Barb Reinhardt" wrote: Never mind. YOu've already looks at SelectionChange. From what I've seen, it needs to be freshly selected to trigger the event. -- HTH, Barb Reinhardt "Ballantine" wrote: I have a vb.net app which includes an excel sheet. I need to detect when a cell has been clicked but there does not appear to be an appropriate event to handle. So far I have handled the "XLSheet.SelectionChange" event to achieve my requirements BUT if the cell in question is ALREADY selected, clicking on it will not raise the above event. I have to click elsewhere so that the selection changes, the result being that data is added to the worksheet in the "wrong" cell. Am I missing something that should be really obvious? I am using vb.net express (2008) and Office 2007 (interop). |
How can I detect that an excel cell has been clicked
After you trigger the selection change event, could you do something like
this so you could select the same cell again Application.EnableEvents = FALSE Target.parent.cells(1,1).select Application.EnableEvents = TRUE -- HTH, Barb Reinhardt "Ballantine" wrote: Thanks for showing some interest and very promptly too. Unfortunately you are only telling me what I already know. Hopefully someone else will have come across the same issue and will tell us how they overcame it. "Barb Reinhardt" wrote: Never mind. YOu've already looks at SelectionChange. From what I've seen, it needs to be freshly selected to trigger the event. -- HTH, Barb Reinhardt "Ballantine" wrote: I have a vb.net app which includes an excel sheet. I need to detect when a cell has been clicked but there does not appear to be an appropriate event to handle. So far I have handled the "XLSheet.SelectionChange" event to achieve my requirements BUT if the cell in question is ALREADY selected, clicking on it will not raise the above event. I have to click elsewhere so that the selection changes, the result being that data is added to the worksheet in the "wrong" cell. Am I missing something that should be really obvious? I am using vb.net express (2008) and Office 2007 (interop). |
How can I detect that an excel cell has been clicked
Thanks again, Barb. Your suggestion is useful. However, since the
worksheets being used by my app might reasonably have 200+ x 200+ used cells I don't want to navigate away from the most recently selected cell. Obviously I could use a "nearby" cell but this workaround starts to get over-complicated when you apply logic to determine an appropriate cell to select - I don't want the range of cells being displayed to change. I must admit, however, that I didn't think of turning event handling off/on. Far too obvious for me!!! "Barb Reinhardt" wrote: After you trigger the selection change event, could you do something like this so you could select the same cell again Application.EnableEvents = FALSE Target.parent.cells(1,1).select Application.EnableEvents = TRUE -- HTH, Barb Reinhardt "Ballantine" wrote: Thanks for showing some interest and very promptly too. Unfortunately you are only telling me what I already know. Hopefully someone else will have come across the same issue and will tell us how they overcame it. "Barb Reinhardt" wrote: Never mind. YOu've already looks at SelectionChange. From what I've seen, it needs to be freshly selected to trigger the event. -- HTH, Barb Reinhardt "Ballantine" wrote: I have a vb.net app which includes an excel sheet. I need to detect when a cell has been clicked but there does not appear to be an appropriate event to handle. So far I have handled the "XLSheet.SelectionChange" event to achieve my requirements BUT if the cell in question is ALREADY selected, clicking on it will not raise the above event. I have to click elsewhere so that the selection changes, the result being that data is added to the worksheet in the "wrong" cell. Am I missing something that should be really obvious? I am using vb.net express (2008) and Office 2007 (interop). |
All times are GMT +1. The time now is 10:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com