Fastest way of using the tools created using VBA in Arc GIS 10?

829
3
Jump to solution
02-01-2012 04:30 PM
MesutCayar
New Contributor
Hello all,

This question might have been asked or discussed before but I have not really found out my answers after my quick search in the forum.

I have this tool that i created using VBA in ArcGIS 9.3. The tool basically selects a feature, finds the related time series table for the selected feature from a geodatabase and creates a time series graph.

We finally migrated to ArcGIS 10 and I just figured out that ArcGIS 10 will be the last version that will be supporting VBA.
I installed the VBA extension for ArcGIS 10 and got the authorization code from ESRI with the hope that the tools created in 9.3 would work right away but unfortunately they did not work.

I am really on a short schedule and in the short run I need to make these tools run.
What would be the best solution for me? Is it possible that I might be missing some references or objects or libraries that changed in version 10? I was hoping that by installing the VBA extension the code would work as it is (It was working fine in version 9.3)

As I run it it gives the follwing error "application define or object defined error" for the following lines

Sub graph_timeseries()
    Dim pDoc As IMxDocument
    Dim pMap1 As IMap
    Dim sLayerName As String
    Dim sCompName1 As String
    Dim sCompName2 As String
    Dim FeatureID() As Integer
   
    Set pDoc = ThisDocument
    Set pMap1 = pDoc.FocusMap
    sLayerName = ""
    sCompName1 = ""
....

Thanks a lot for the help already.

Mesut
0 Kudos
1 Solution

Accepted Solutions
DuncanHornby
MVP Notable Contributor
Mesut,

I am having similar problems getting old 9.3 VBA projects up and running in 10. I too was getting unexplained compile problems on seemingly innocent lines of code. This is what I did:

  1. Save a copy as a version 10 mxd and work from that

  2. go into vba editor menu > references and untick all esri references.

  3. recompile vba project and save.

  4. In 9.3 recompiling would have caused arcmap to say don't know IMap etc and one would add back the appropriate object library but in 10 it seemed to know and add them back, may happen for you?

  5. recompile and if it objects to a line go to it. I found for example it did not like my reference to IStatusbar so I had to re-write the line to include the library so I was retyping dim pSB as esriSystem.IStatusbar.

  6. Recompile and correct any other lines.

So no code needed altering other than declaration lines. All very odd!

Duncan

View solution in original post

0 Kudos
3 Replies
DuncanHornby
MVP Notable Contributor
Mesut,

I am having similar problems getting old 9.3 VBA projects up and running in 10. I too was getting unexplained compile problems on seemingly innocent lines of code. This is what I did:

  1. Save a copy as a version 10 mxd and work from that

  2. go into vba editor menu > references and untick all esri references.

  3. recompile vba project and save.

  4. In 9.3 recompiling would have caused arcmap to say don't know IMap etc and one would add back the appropriate object library but in 10 it seemed to know and add them back, may happen for you?

  5. recompile and if it objects to a line go to it. I found for example it did not like my reference to IStatusbar so I had to re-write the line to include the library so I was retyping dim pSB as esriSystem.IStatusbar.

  6. Recompile and correct any other lines.

So no code needed altering other than declaration lines. All very odd!

Duncan
0 Kudos
MesutCayar
New Contributor
Duncan,

Thanks for the tips.
Just saving the map in ArcGIS 10 get the work done for me. Very odd but it is working...
The tool is working now.

This was a temporary fix to my problem but I guess in the long run I have to migrate the tool.
What would be the best, efficient, and fastest option doing that? Any suggestions out there?

Mesut
0 Kudos
DuncanHornby
MVP Notable Contributor
To future proof your tool and as you know vba I would start using vb. Net. You will need visual studio 2010. In version 10 they have introduced addins which are much easier to distribute.
0 Kudos