Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
about a year ago, I searched this forum and I saw a sample (.NET) showing the form in a relative position compared to the specified cell,
In VBA, I would need to use a fairly sophisticated API to do this, but now I can use .NET. No more remembering the keyword to find it. I tried searching and it looks like I will need "PointsToScreenPixelsY" and "PointsToScreenPixelsX" but I'm worried that I might miss anything..
Can you give me a solution?
Many thanks!


What I have tried:

With ActiveWindow
    UserForm1.Left = .PointsToScreenPixelsX(cell.Left)
    UserForm1.Top = .PointsToScreenPixelsY(cell.Top)
End With
Posted
Updated 27-Apr-20 2:49am

PointsToScreenPixelsX and PointsToScreenPixelsY are Excel methods of a Window, or a Pane.

The values returned are pixel values; to set a Form's position, you must convert the pixel values to Points. See: [^].

You can find what appears to be a complete solution for your question here: [^].

Caution: I do not have Excel on this machine, and cannot test this using C# automation.
 
Share this answer
 
Comments
Maciej Los 30-Apr-20 1:31am    
5ed!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900