I have a requirement to set the layout view scale as data view in order to be able to print the same layer shown at the data view scale
so i tried the following code to set the layout view scale
Public Shared Sub SetLayoutViewScale(ByVal newScale As Double) Dim pActiveView As ESRI.ArcGIS.Carto.IActiveView Dim pMap As ESRI.ArcGIS.Carto.IMap Dim dblDiff As Double Dim dblMapScale As Double
Try pActiveView = CType(My.ArcMap.Document.PageLayout, ESRI.ArcGIS.Carto.IActiveView) pMap = pActiveView.FocusMap pMap.MapScale = newScale ' The problem is in this line pActiveView.Refresh() Catch ex As Exception MsgBox("Can't set layout scale")
End Try End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' but the problem occurs in this line pMap.MapScale = newScale
The MapScale property does not accept the value of newScale and may take different scale.
I have tried to setup arc10.1 sp1 for arcdesktop and ard10.1 sp1 for .net framework sdk
But the same error still occurs.
I have also tried to use the following code Public Shared Sub SetMapExtentFromScale(ByVal newScale As Double) 'Get coordinates of current map extent Dim pExtent As ESRI.ArcGIS.Geometry.IEnvelope Dim dblXMin As Double, dblXMax As Double, dblYMin As Double, dblYMax As Double Dim pActiveView As ESRI.ArcGIS.Carto.IActiveView Dim pCenterPoint As ESRI.ArcGIS.Geometry.IPoint Dim pCenterScale As ESRI.ArcGIS.Carto.ICenterAndScale
'Assign center point and map scale to new CenterAndScale object
pCenterScale = New ESRI.ArcGIS.Carto.CenterAndScale pCenterScale.Center = pCenterPoint pCenterScale.MapScale = newScale
'Assign new CenterAndScale object to MapDescription pActiveView.Extent = CType(pCenterScale, ESRI.ArcGIS.Carto.IMapArea).Extent pActiveView.Refresh()
Catch ex As Exception MsgBox("Can't set layout scale")
End Try
End Sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' but CType(pCenterScale, ESRI.ArcGIS.Carto.IMapArea).Extent throws an exception
So any help to set the layout scale or workaround would be appreciated.