DennisJongsomjit

how to use macro and .bas file

Discussion created by DennisJongsomjit on May 26, 2010
Latest reply on May 27, 2010 by DennisJongsomjit
Hi,

I have some vba code (below) and a .bas file that I'm trying to add to add as an available macro tool. I've loaded the code into the normal.mxt ThisDocument page. I then loaded the .bas file into the modules folder as a new module. But when I go to Tools -> Customize -> Commands tab -> Macros the macro does not appear as a command option. Can anyone guide me here or point me to a helpful site. I had done this before successfully.... but have since gotten a new computer. The macros runs through rasters in a project and exports pngs for each one. Any help is appreciated.  What am I doing wrong?!

Thanks,

DJ

 
Private Sub ExportRFPMaps_Click()
    'MapTasks.ZoomToLayer
    'Create variables for map and extent
    Dim pMxDoc As IMxDocument
    Dim pMap As IMap
    Dim pActiveView As IActiveView
    Dim pEnv As IEnvelope
    Dim strTitle As String
    
    
    'Set the current map
    Set pMxDoc = ThisDocument
    Set pMap = pMxDoc.FocusMap
    Set pActiveView = pMap
    
    'Loop through the RFP layers turning them on, setting the map title and exporting a .png
    'Make sure all RFP layers are off when running the tool or one layer may show up in another's view
    For i = 1 To pMap.LayerCount - 1
        If pMap.Layer(i) Is Nothing Then Exit Sub 'Test that there is a layer
        pActiveView.Extent = pMap.Layer(i).AreaOfInterest 'Set the extent to the layers extent
        Set pEnv = pActiveView.Extent 'Set the envelope object equal to the current extent
        pEnv.Expand 1.1, 1.1, True 'Expand the envelope by 10%
        pActiveView.Extent = pEnv 'Set the extent equal to the expanded envelope
        pMap.Layer(i).Visible = True 'Make current layer visible
        strTitle = MapTasks.FormatTitle(pMap.Layer(i).Name) 'Format the title into two lines
        Call MapTasks.ChangeTitle(strTitle) 'Assign the map title with the change title subc
        Call MapTasks.ExportMap("Z:\Informatics\S031\analyses\RossSeaMPA\Modeling\images\eucl_dist\" & pMap.Layer(i).Name & ".png") 'Export map with export map sub
        'Turn the layer off unless its the last layer
        If i = pMap.LayerCount - 1 Then pMap.Layer(i).Visible = True Else pMap.Layer(i).Visible = False
    Next
    
    'Let user know when its done
    MsgBox "Export Complete!  Files exported to:" & vbCrLf & "Z:\Informatics\S031\analyses\RossSeaMPA\Modeling\images\eucl_dist", vbOKOnly
    
End Sub

Outcomes