+ Reply to Thread
Results 1 to 4 of 4

XY Coordinates of activeCell?

Hybrid View

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

    XY Coordinates of activeCell?

    Is there anyway to determine the xy(z?) coorinates of the activeCell? I want to get this data so that I can use SetMousePos to position the mouse onto the activeCell.

    TIA.

    Bob

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: XY Coordinates of activeCell?

    You may be looking for the .Top, .Left, .Height and .Width properties of a Range.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

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

    Re: XY Coordinates of activeCell?

    Not in terms of cells but in terms of "twips" (I think) so that I can use that information to relocate my mouse to the active cells.

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

    Re: XY Coordinates of activeCell?

    I'm working in the current direction. It will reposition the mouse but not to the correct location. Any ideas where I'm going wrong?

    TIA.

    Bob

    Type pointapi
        x As Long
        y As Long
    End Type
    Declare Function GetCursorPos Lib "user32" (lpPoint As pointapi) As Long
    Declare Function SetCursorPos Lib "user32" (ByVal xx As Long, ByVal yy As Long) As Long
    Public pos As pointapi
    Sub Macro1()
        Dim x, y As Long
        
        GetCursorPos pos
        MsgBox "Cursor Pos.x = " + Str(pos.x)
        MsgBox "Cursor Pos.y = " + Str(pos.y)
        
        x = ActiveWindow.PointsToScreenPixelsX(ActiveWindow.ActiveCell.Top)
        y = ActiveWindow.PointsToScreenPixelsY(ActiveWindow.ActiveCell.Left)
        
        MsgBox "activeCell.top = " + Str(x)
        MsgBox "activeCell.left = " + Str(y)
        
        Call SetCursorPos(x, y)
        
    End Sub

+ 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