Adding layer file - Automation Error, Invalid Pointer, VBA code help

chris.blinn799

New member
Local time
Yesterday, 23:16
Joined
Oct 28, 2009
Messages
4
I've wrote code to add 4 files into ArcMap. The first 3 add featureclasses and work perfect, but this layer will not add due to a Automation Error, Invalid Pointer, which pops up when I run the code. The debug takes me to the line with the comment depicting the error. I do not know how to fix this, any suggestions?!

THANKS and BEST,
Chris

Code:
Private Sub AddLayerFile()


    Dim pMxDoc As IMxDocument
    Dim pMap As IMap
    Dim pGxLayer As IGxLayer
    Dim pGxFile As IGxFile

    'Get the layer file
    Set pGxLayer = New GxLayer
    Set pGxFile = pGxLayer
    pGxFile.Path = "E:\GEOG423\Projects\Group\Data\Small Street Names.dwg"

    'Add the layer to the map
    Set pMxDoc = ThisDocument
    Set pMap = pMxDoc.FocusMap
    pMap.AddLayer pGxLayer.Layer
    pMxDoc.ActiveView.Refresh
End Sub
 

Users who are viewing this thread

Back
Top Bottom