I'm fairly new to this project and to VB and got some of old code to fix. The task is to click a polygon on the screen with the mouse and then save it to a shapefile.

When executing the code, it breaks with the error message:

Run-time error -2147467259 (80004005) Automation error

The debugger turns to this line where the destination shapefile is opened:

Set pWorkspace = pWorkspaceFactory.OpenFromFile("I:\Projekte\LBDatenBank\Karten\Bildrahmen.shp", 0)

I: is a network drive.

I did some research and it seems that the WorkspaceFactory does not usually open shapefiles, yet this code used to work without changes a few months ago.

If I change the string to a path to a directory or something else the error stays the same. Even if I enter no path at all and just random characters.

I think the problem might be within the OS?

closed as off-topic by PolyGeo Oct 25 '18 at 6:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Welcome to GIS SE! We're a little different from other sites. We're a Q&A site, not a discussion forum. For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely. Please check out our short tour for more about how the site works. Thanks. – PolyGeo Oct 25 '18 at 6:55
  • A workspacefactory is used to create a workspace so you're right it's not used to open a file but in this case OpenFromFile is used to open a folder which is the workspace a shapefile lies in. Check your path actually exists and your workspace factory is instantiated set pWorkspaceFactory = new ShapefileWorkspaceFactory beforehand. resources.arcgis.com/en/help/arcobjects-net/componenthelp/… the OpenFromFile method is also used to open SDE files and Access databases (.mdb) if the workspace factory is of the right coclass. – Michael Stimson Oct 25 '18 at 7:18
  • 2
    Get rid of the name of the shapefile in your workspace factory OpenFromFile and open the folder it's in, after confirming the path is ok, then to open the shapefile use the workspace as IFeatureWorkspace Open method resources.arcgis.com/en/help/arcobjects-net/componenthelp/… and use just the file name because the path is already known... does that make more sense? PS the ArcObjects help works for VBA as well, there are only a few differences, most notably the use of the set keyword, apart from that they're almost identical to VB.net in their operation. – Michael Stimson Oct 25 '18 at 7:24