View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How to programmatically set a focus on the selected cell?

You can turn off event handling before you make the change, then make the
changes, then turn the event handling back on.

moExcelApp.EnableEvents = False
moExcelApp.Cells(69,11).Value = "Mush"
moExcelApp.EnableEvents = True

Jack wrote:

Thank you very much
This works for me:
moExcelApp.EnableEvents = False
moExcelApp.Cells(CurrentRow, CurrentCol).Select
moExcelApp.EnableEvents = True

I do not understand the first part:
When I tried:
moExcelApp.Cells(69,11).Value = "Mush"
the event moExcelApp_SheetChange is fired.
Jack

"Jim Cone" wrote in message
...

Again ...
You don't have to select the cell. Also, you do not have to
select the sheet. WS.Cells(69, 11).Value = "Mush" will work from
almost anywhere. No selection then no selection change event occurs.

However, to prevent events from occurring use
moExcelApp.EnableEvents = False.
Events remain off until reset to True by your code.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Jack" <replyto@it wrote in message
Thank you.
However, when I do that the
moExcelApp_SheetSelectionChange is invoked.
How can I do that (setting the focus) without invoking that function?
Jack

"Jack" <replyto@it wrote in message
...
Hi,
Using Excel automation, how to set a focus (rectangle around the
cell) , by specifying Column No and Row No.?
Thanks,
Jack




--

Dave Peterson