+ Reply to Thread
Results 1 to 7 of 7

Mouse Relocation to ActiveCell

  1. #1
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Mouse Relocation to ActiveCell

    I've got an application where I switch between workSheets and the mouse stays in the same location. As all of my actions are predicated on mouse right-clicks or double-clicks, the first thing that I have to do as move the mouse back to the active cell. Is there a way to reposition the mouse to the activeCell upon returning to the workSheet?

    TIA.

    Bob
    Last edited by bstubbs; 11-28-2009 at 12:10 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Mouse Relocation to ActiveCell

    suppose the active cell is A1 in sheet 1

    right click the sheet1 tab and click viewcode and copypaste this code (modifyto suit you)

    Please Login or Register  to view this content.

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Mouse Relocation to ActiveCell

    venkat, that does not do anything with the mouse pointer at all! The OP wants to move the mouse pointer!

    bstubbs, AFAIK things like this would involve the Windows32 API. See if this helps http://www.ozgrid.com/forum/showthread.php?t=32765
    Last edited by teylyn; 11-24-2009 at 12:42 AM.

  4. #4
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: Mouse Relocation to ActiveCell

    Yeah, I think that this will work for me. Thanks.

    Next, since this works on screen coordinates, any ideas on how to determine the screen coordinates of the active cell?

    Thanks.

    Bob

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Mouse Relocation to ActiveCell

    nice one. No clue. Maybe this is worth a new post to catch the attention of the knowledgeable VBA crew. Given it's a whole new ball game...

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Mouse Relocation to ActiveCell

    Have a look at the FormPositioner workbook available on Chip Pearson's site here.
    In versions pre 2007, you can also create a zero sized chart at the cell location, activate it, use FindWindow (looking for an "EXCELE" class window) to get its handle and get the coordinates from that. Doesn't work for 2007 as the chart window doesn't exist any more unfortunately (though you can kludge it with sendkeys and finding the in-cell editing window.)
    Remember what the dormouse said
    Feed your head

  7. #7
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: Mouse Relocation to ActiveCell

    I got it to work using GetCursorPos and SetCursorPos functions, but I have to set variables for each such move. It will be a lot more flexible if I can just move the mouse to the activeCell of the activePage. Is there anyway to determine the xy(z?) coorinates of the activeCell?

    Bob

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1