Calculating the Screen TwipsPerPixelX and Y

B

Byzantine

Hallo there

I'm trying to determine what my screen TwipsPerPixelX (horixontal) and
TwipsPerPixelY (vertical) are using MS Access 2003 VBA.

I understand that the code in VB is as follows:
Screen.TwipsPerPixelX
Screen.TwipsPerPixelY

Yet if I try to use this code in VBA it doesn't appear to work: I get the
following compile error message:

'Method or data member not found'.

Does anyone know the VBA equivalent?

Any help is greatly appreciated.
 
L

Larry Linson

The Screen object in the separate VB product has a TwipsPerPixel property.
Access' Screen object does not. It isn't a "language difference" but a
"product object model difference"

I've been developing in Access since Version 1.0 and have never suffered for
the lack. Perhaps if you'd explain what you are trying to accomplish,
someone could make a worthwhile suggestion.

Larry Linson
Microsoft Access MVP
 
B

Byzantine

Larry, thanks for the quick response.

I'm trying to reset the scale of a map each time its extent changes on my
form, using ESRI's MapObjects2 ActiveX controls (the Map control object and
scalebar object). I'm told by ESRI that the VB code to do this is as follows:

Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As Long)

'Set the ScaleBar's MapExtent
With ScaleBar1.MapExtent
.MinX = Map1.Extent.Left
.MinY = Map1.Extent.Bottom
.MaxX = Map1.Extent.Right
.MaxY = Map1.Extent.Top
End With

'Set the ScaleBar's PageExtent
With ScaleBar1.PageExtent
.MinX = Map1.Left / Screen.TwipsPerPixelX
.MinY = Map1.Top / Screen.TwipsPerPixelY
.MaxX = (Map1.Left + Map1.Width) / Screen.TwipsPerPixelX
.MaxY = (Map1.Top + Map1.Height) / Screen.TwipsPerPixelY
End With

'Refresh the ScaleBar after the Map has changed
ScaleBar1.Refresh
MsgBox "1: " & Format$(ScaleBar1.RFScale, "###,###,###,###,###")
'Label1.Caption="1: " & Format$(ScaleBar1.RFScale,"###,###,###,###,###")

End Sub

The routine falls down at the 'Screen.TwipsPerPixelX' code because of the
product object model difference between VB and VBA.

The ScaleBar1 object is an ESRI MapObjects2.1 scale bar and the Map1 object
is the ESRI MapObjects2 Map control.

ESRI do not appear to have sufficient expertise in MS Access VBA, so I hope
that MS Access experts can help.

Many thanks for continued assistance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top