Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2007

Tip: Looking for answers? Try searching our database.

How to programmatically set a focus on the selected cell?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack - 07 Apr 2007 00:32 GMT
Hi,
     Using Excel automation, how to set a focus (rectangle around the cell)
, by specifying Column No and Row No.?
Thanks,
Jack
Barb Reinhardt - 07 Apr 2007 00:40 GMT
Cells(rownumber,columnnumber).select

> Hi,
>       Using Excel automation, how to set a focus (rectangle around the cell)
> , by specifying Column No and Row No.?
> Thanks,
> Jack
Jim Cone - 07 Apr 2007 00:47 GMT
Providing you have a properly declared worksheet object then...
  WS.Cells(Rw, Col).Select
Rw is the row number and Col is the Column number and both
should be a Long.

Also, you do not need to Select in order to "work" on a cell, just
use the reference...  WS.Cells(69, 11).Value = "Mush"
Signature

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

Hi,
     Using Excel automation, how to set a focus (rectangle around the cell)
, by specifying Column No and Row No.?
Thanks,
Jack
Jack - 07 Apr 2007 04:12 GMT
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

> Hi,
>      Using Excel automation, how to set a focus (rectangle around the
> cell) , by specifying Column No and Row No.?
> Thanks,
> Jack
Jim Cone - 07 Apr 2007 04:59 GMT
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.
Signature

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
news:uQ0DZPKeHHA.4188@TK2MSFTNGP02.phx.gbl...

> Hi,
>      Using Excel automation, how to set a focus (rectangle around the
> cell) , by specifying Column No and Row No.?
> Thanks,
> Jack
Jack - 07 Apr 2007 06:12 GMT
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

> Again ...
> You don't have to select the cell.  Also, you do not have to
[quoted text clipped - 9 lines]
>> Thanks,
>> Jack
Dave Peterson - 07 Apr 2007 13:54 GMT
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

> Thank you very much
> This works for me:
[quoted text clipped - 35 lines]
> >> Thanks,
> >> Jack

Signature

Dave Peterson

Jack - 07 Apr 2007 04:31 GMT
reversing my original question:
How to remove programmatically focus (rectangle) from the cell?
Jack

> Hi,
>      Using Excel automation, how to set a focus (rectangle around the
> cell) , by specifying Column No and Row No.?
> Thanks,
> Jack
Dave Peterson - 07 Apr 2007 13:56 GMT
Something has to be selected.  You could select a different range (out of the
visible area???) or select an object.

But I think Jim's point was that if you don't include .select's in your code,
you don't have to worry about going back to where you started.

> reversing my original question:
> How to remove programmatically focus (rectangle) from the cell?
[quoted text clipped - 5 lines]
> > Thanks,
> > Jack

Signature

Dave Peterson


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.