Hmm. Thanks for the tip. However...I changed it to Public and that allowed me to access the macro and add it to my toolbar. But, it's acting funny now. I wonder if it has to do with the change from 9.2 to 9.3.1 (given that it worked before without a hitch)?When I have one or no grids loaded the macro seemingly works correctly (get a success message) but no image is created. It checks for layers so it's odd that it doesn't balk when there are no grids loaded.When I have two or more grids loaded it brings up an error "Invalid procedure call or argument".I've included the code from the .bas module I created within my normal.mxt modules folder. Got a chance to look it over for obvious errors? Thanks again for any help.
Public Sub ChangeTitle(txtTitle As String)
'Create variables for map
Dim pMxDoc As IMxDocument
Dim pActiveView As IActiveView
'Create variables for the graphics
Dim pGraphicsContainer As IGraphicsContainer
Dim pElement As IElement
Dim pTextElement As ITextElement
'Set the current map, layout, and graphics container
Set pMxDoc = ThisDocument
Set pActiveView = pMxDoc.ActiveView
Set pPageLayout = pMxDoc.PageLayout
Set pGraphicsContainer = pPageLayout
Dim pMSF As IMapSurroundFrame
Dim pMS As IMapSurround
'Reset the graphics container list to return the first graphic
'The text title is the first graphic on the page layout because it is at the top of the order
'If you change the order of the text title the following code will not work
pGraphicsContainer.Reset
Set pElement = pGraphicsContainer.Next
Set pTextElement = pElement
pTextElement.Text = txtTitle 'This actualy changes the title.
'Refresh all the map elements
pGraphicsContainer.Reset
Set pElement = pGraphicsContainer.Next
Do Until pElement Is Nothing
If TypeOf pElement Is IMapSurroundFrame Then
Set pMSF = pElement
Set pMS = pMSF.MapSurround
pMS.Refresh
pMxDoc.ActiveView.Refresh
End If
Set pElement = pGraphicsContainer.Next
Loop
End Sub
Public Sub ExportMap(strFileName As String)
'Create variables for map and extent
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pActiveView As IActiveView
Dim pEnv As IEnvelope
'Set the current map
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap
Set pActiveView = pMap
'Create export object and set the resolution
Dim pExport As IExport
Set pExport = New ExportPNG
pExport.Resolution = 450
'Set the export frame
Dim exportRECT As tagRECT
exportRECT = pMxDoc.ActiveView.ExportFrame
'Set the size and extent of the export
Dim pPixelBoundsEnv As IEnvelope
Set pPixelBoundsEnv = New Envelope
pPixelBoundsEnv.PutCoords exportRECT.Left, exportRECT.bottom, exportRECT.Right, exportRECT.Top
'pPixelBoundsEnv.PutCoords 0, 2477, 4050, 0
pExport.PixelBounds = pPixelBoundsEnv
'Create a cancel object
Dim pCancel As ITrackCancel
Set pCancel = New CancelTracker
'Set file name and export map
pExport.ExportFileName = strFileName
pMxDoc.ActivatedView.Output pExport.StartExporting, pExport.Resolution, exportRECT, Nothing, pCancel
pExport.FinishExporting
pExport.Cleanup
End Sub
Public Function FormatTitle(strTitle As String) As String
Dim strFirstLine As String
Dim strSecondLine As String
Dim lngLength As Long
Dim lngPosition As Long
lngLength = Len(strTitle)
lngPosition = InStr(strTitle, "Return Flow Plot")
strFirstLine = Left(strTitle, lngPosition - 1)
strSecondLine = Right(strTitle, lngLength - lngPosition + 1)
FormatTitle = strFirstLine & vbCrLf & strSecondLine
End Function