resizing columns with pixels

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

I want to be able to specify column widths in pixels
rather than points. I can call the function for column
widths in VBE but can't find an option to specify a width
in pixels (even though this value is always shown when
manually resizing)

Help would be great,
Cheers
Andy
 
Hi Andy;
MsgBox Columns(1).ColumnWidth ' Points
MsgBox Columns(1).ColumnWidth * 4 / 3 ' Pixels
 
Ta for the suggestion but it doesn't work. I have tried
to find a relationship between points and pixels but as
points are based on the standard font size the bigger the
column width the more (different sized letters) can fit
in. I do know that the relationship is definatley not
linear. I think I need to actually specify number of
pixels rather than converting into points

Any ideas?

Andy
 
Andy said:
Ta for the suggestion but it doesn't work. I have tried
to find a relationship between points and pixels but as

Have you looked at the methods PointsToScreenPixelsX and
PointsToScreenPixelsY of the Window object?
 
Hi Andy; test this:

Private Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Sub PixelsPointsRate()
Application.WindowState = xlMaximized
Dim R As RECT
GetWindowRect Application.hwnd, R
MsgBox "Pixels -> Points: " & Application.Width / (R.Right - R.Left)
End Sub

If Pixels to Points = 3/4 Then Points To Pixels = 4/3 !

"Andy" <[email protected]> a écrit dans le message de
Ta for the suggestion but it doesn't work. I have tried
to find a relationship between points and pixels but as
points are based on the standard font size the bigger the
column width the more (different sized letters) can fit
in. I do know that the relationship is definatley not
linear. I think I need to actually specify number of
pixels rather than converting into points

Any ideas?

Andy
 
Sorry Andy;
You must use the width property and not columnwidth.
MsgBox Columns(1).Width 'Points
MsgBox Columns(1).Width * 4 / 3 'Pixels
Regards
 
Back
Top