1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Option Explicit
Declare PtrSafe Function GetDC& Lib "user32.dll" (ByVal hwnd&)
Declare PtrSafe Function GetDeviceCaps& Lib "gdi32" (ByVal hDC&, ByVal nIndex&)
Sub position_usf(usf, cel)
' 1 inch = 72 points for usually 96 or 120 dpi
Dim x As Double, y As Double
x = GetDeviceCaps(GetDC(0), 88) / 72
y = GetDeviceCaps(GetDC(0), 90) / 72
With usf
.StartUpPosition = 0
.Left = (ActiveWindow.PointsToScreenPixelsX(cel.Left * x) * 1 / x)
.Top = (ActiveWindow.PointsToScreenPixelsY(cel.Top * y) * 1 / y)
End With
ActiveWindow.ScrollRow = cel.Row
ActiveWindow.ScrollColumn = cel.Column
End Sub |