Nelson,
You will need to compute the value on your system, Pixel to
Inches/Centimeter is depend on the system metrics. 1440 twips = 1 inch.
Hence determine the number of twips in 1 pixel. A pixel may not be square
hence compute the for X as well as Y.
Note that while converting to centimeter the version of PowerPoint is
essential. Older versions used it's own concept of centimeter which was
smaller than the actual centimeter for convinience.
' ------------------------------------------------------------------------------
Option Explicit
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
Const TWIPSPERINCH As Long = 1440
Const LOGPIXELSX As Long = 88
Const LOGPIXELSY As Long = 90
Function TwipsPerPixelX() As Single
Dim lngDC As Long
lngDC = GetDC(0)
TwipsPerPixelX = TWIPSPERINCH / GetDeviceCaps(lngDC, LOGPIXELSX)
ReleaseDC 0, lngDC
End Function
Function TwipsPerPixelY() As Single
Dim lngDC As Long
lngDC = GetDC(0)
TwipsPerPixelY = TWIPSPERINCH / GetDeviceCaps(lngDC, LOGPIXELSY)
ReleaseDC 0, lngDC
End Function
Sub PixelsToInches()
Dim PixelX As Single
Dim PixelY As Single
PixelX = 800
PixelY = 474
MsgBox CStr(PixelX) & " X pixels are equivalent to : " & CStr(TwipsPerPixelX
* PixelX / TWIPSPERINCH) & " inches."
MsgBox CStr(PixelY) & " Y pixels are equivalent to : " & CStr(TwipsPerPixelY
* PixelY / TWIPSPERINCH) & " inches."
End Sub
' ------------------------------------------------------------------------------