Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7494923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:51:23+00:00 2026-05-29T17:51:23+00:00

How can I find the absolute coordinates in pixels of a certain cell? I

  • 0

How can I find the absolute coordinates in pixels of a certain cell?

I am developing an Office 2010 addon (the Ribbon UI) and I add a new button to a new menu in the Ribbon and when the button is pressed, I want to get the screen position of that cell. The problem is that

Globals.ThisWorkbook.Application.ActiveCell . Top / Left

only give the position relative to the A1 corner of the spreadsheet, while I want the position relative to 0,0 of the screen.

I found this: How to get screen X and Y of an Excel 2003 cell in C# but it’s for Office 2003 and I don’t fully understand the answer.

I’m using C# for devel, but VB will also do.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T17:51:26+00:00Added an answer on May 29, 2026 at 5:51 pm

    I found this post, which contains the API calls used below. I also was reminded that you can get the height of the ribbon with Application.Commandbars(“Ribbon”).Height. So, in VBA you’d do:

    EDIT: In response the Formula Bar and Headings height issue I added a function that hides them, gets the ActiveWindow.Height, then shows them and gets the new ActiveWindow.Height and figures the difference. That function now gets called in the line below that adds together the heights before converting. I think it works but I didn’t do a lot of testing.

    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
    Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
    Private Const LOGPIXELSX As Long = 88
    Private Const LOGPIXELSY As Long = 90
    
    Sub CellTopLeftPixels(rng As Excel.Range)
    Dim RibbonHeight As Long
    Dim TotalTop As Long
    Dim TotalLeft As Long
    
    RibbonHeight = Application.CommandBars("Ribbon").Height
    TotalTop = (RibbonHeight + GetFormulaBarAndHeadingsHeight + rng.Top) * PixelsPerPointY
    TotalLeft = rng.Left * PixelsPerPointX
    Debug.Print "Top: "; TotalTop; " Left: "; TotalLeft
    End Sub
    
    Function GetFormulaBarAndHeadingsHeight()
    Dim ActiveWindowHeightWhenHidden As Long
    Dim ActiveWindowHeightWhenShown As Long
    
    Application.DisplayFormulaBar = False
    ActiveWindow.DisplayHeadings = False
    ActiveWindowHeightWhenHidden = ActiveWindow.Height
    Application.DisplayFormulaBar = True
    ActiveWindow.DisplayHeadings = True
    ActiveWindowHeightWhenShown = ActiveWindow.Height
    GetFormulaBarAndHeadingsHeight = ActiveWindowHeightWhenHidden - ActiveWindowHeightWhenShown
    End Function
    
    Function PixelsPerPointX() As Double
    Dim hdc As Long
    Dim PixPerInchX As Long
    
    hdc = GetDC(0)
    PixPerInchX = GetDeviceCaps(hdc, LOGPIXELSX)
    PixelsPerPointX = PixPerInchX / 72
    ReleaseDC 0, hdc
    End Function
    
    Function PixelsPerPointY() As Double
    Dim hdc As Long
    Dim PixPerInchY As Long
    
    hdc = GetDC(0)
    PixPerInchY = GetDeviceCaps(hdc, LOGPIXELSY)
    PixelsPerPointY = PixPerInchY / 72
    ReleaseDC 0, hdc
    End Function
    

    The 72 above is the points per inch.

    Call it like:

    Sub test()
    CellTopLeftPixels ActiveCell
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I find the absolute position of the paper/canvas when using the Raphael
I couldn't find answers for html5 canvas. Can I change the coordinates of the
Where can find resources about best practices for SharePoint programming? I am talking about
I can find no non-deprecated way of hiding an item in a menu bar
I can find the definition files at http://www.php.net/~helly/php/ext/spl/... but I want to extend DirectoryIterator
I can find out the error in my apps. When am trying to execute
I can find ample evidence that MongoDBs are always kept in the order given
Can somebody tell me how I can find out how many threads are in
Can anyone tell me how I can find out if an SPField object is
can you please tell me how I can find the age of a webpage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.