vba cant open shapefile

Nov 18, 2011 at 8:25 AM

Hi,

I'm using the late-binding method to open a shapefile, but somehow its throwing up an error (Type Mismatch) in the sf.open line.

Can anyone please help? What am I doing wrong??

 

Dim sf As Object
Dim Filename As String

Filename = "E:\Develop\TasSpan\Bridgemaster\shapefiles\cities.shp"
Set sf = CreateObject("MapWinGIS.Shapefile")

If sf.Open(Filename) = False Then 'here's the error!!!

Coordinator
Nov 20, 2011 at 7:03 PM

Is it really necessary to use late binding?

Did you check if sf is not Nothing before opening a file?
I never use late binding. Are you sure the object name is "MapWinGIS.Shapefile" isn't it "MapWinGIS.ShapefileClass"

Jan 16, 2012 at 11:00 PM

Hi

Still cant resolve this problem.

I need to use late binding as it needs to compile whether or not MapWINGIS is installed.

I want to test for installation programatically

sf is not nothing. It is an object. I've tested that.

And MapWinGIS.Shapefile is the correct name, not MapWinGIS.ShapefileClass

Can someone please help

Thanks

Brian

 

Jan 17, 2012 at 10:23 PM

Finally resolved the issue. It expects an object (so nothing)

Here's the working code:

Dim sf As Object
Dim Filename As String

Filename = "E:\Develop\TasSpan\Bridgemaster\shapefiles\cities.shp"
Set sf = CreateObject("MapWinGIS.Shapefile")

If sf.Open(Filename, Nothing) = False Then