I have a macros function that worked in 9.3 but it is sketchy in 10. When I run the macros it brings up the window where I can type my desired page size in. The problem happens when I edit some data or change something on the mxd. When I run the macros, all of my data and the data frame shrinks down into the bottom corner. It never used to do this in 9.3! Any ideas?
Sub PageSize()
Dim pMxDoc As IMxDocument
Dim pPage As IPage
Dim pDialog As ICoordinateDialog
Dim pActiveView As IActiveView
Set pMxDoc = Application.Document
Set pActiveView = pMxDoc.PageLayout
Set pPage = pMxDoc.PageLayout.Page
Set pDialog = New CoordinateDialog
If pDialog.DoModal("Enter new page size", 8.5, 11, 2, Application.hWnd) Then
pPage.PutCustomSize pDialog.X, pDialog.Y
pActiveView.Refresh
End If
Dim pMxDocument As IMxDocument
Set pMxDocument = ThisDocument
Dim pGraphicContainer As IGraphicsContainer
Set pGraphicContainer = pMxDocument.PageLayout
Dim pElement As IElement
Dim pFrameElement As IFrameElement
Dim pEnvelope As IEnvelope
pGraphicContainer.Reset
Set pElement = pGraphicContainer.Next
Do While Not pElement Is Nothing
If TypeOf pElement Is IMapFrame Then
Set pFrameElement = pElement
Set pEnvelope = pElement.Geometry.Envelope
With pEnvelope 'set position in page unit
.XMin = 0
.XMax = pDialog.X
.YMin = 0
.YMax = pDialog.Y
End With
pElement.Geometry = pEnvelope
End If
Set pElement = pGraphicContainer.Next
Loop
If TypeOf pMxDocument.ActiveView Is IPageLayout Then pMxDocument.ActiveView.Refresh
End Sub