• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Align Userform Next To The Clicked Cell

kadrleyn

Member
It may be more useful to display this userform next to the active cell that was clicked, rather than in the center of the sheet.

By declaring the GetDeviceCaps , GetDC , ReleaseDC
functions , I repositioned the userform next to each the clicked
activecell .(The template is checked in 32-bit and 64-bit Excel versions )

78469

Code:
Type POINTAPI

X As Long

Y As Long

End Type

#If VBA7 Then

Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hDc As LongPtr, ByVal nIndex As Long) As Long

Declare PtrSafe Function GetDC Lib "user32" (ByVal hwnd As LongPtr) As LongPtr

Declare PtrSafe Function ReleaseDC Lib "user32" (ByVal hwnd As LongPtr, ByVal hDc As LongPtr) As Long

Dim hDc As LongPtr

#Else

Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDc As Long, ByVal nIndex As Long) As Long

Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDc As Long) As Long

Dim hDc As Long

#End If

...

Source & sample file
 
  • Like
Reactions: Hui
Back
Top