Opening up an old VBA form via Add-In

1589
5
04-27-2011 10:55 AM
deleted-user-yA_w_FC9FKe5
New Contributor III
Okay I am really new to the whole Add-In and I am trying to go baby steps to move over.  What I would like to do is try to make the conversion slowly over to vb.net or C#.  Since I am a VB guy I am going with VB.Net.  However, I don't understand VB.Net it actually really confuses me for some reason.

Anyway, It seems as though my code still works in 10.0 but while my menus came in, none of my buttons came in when opening up my old 9.3 mxd in 10.0.  Please keep in mind I have well over 50,000 pages of code to convert.  We have a lot invested into VBA. 

My problem:
I was trying to us Add-ins to create a button to call my forms.  I've gotten my button to post a message "Hello World".  I've even created another button that allows me to add some shapefiles in.  Yeah.  However, what I really really need right now is to be able to call these forms.  It would save me tremendous time and allow me to do this conversion slowly while giving my users the latest mxd functionality. 

So how can I do this????  Thanks in advance.
0 Kudos
5 Replies
JamesCrandall
MVP Frequent Contributor
I am really in the unknown class when it comes to these Add-in things, but I can comment on opening Userforms....

So, let's say I have a button on a toolbar that needs to open a WindowsForm that I have added to my project/assembly.  Let's call it "frmMain".  So, in my class that has the Button's Click event, I would state what the frmMain is:


Private m_frmMain As frmMain



Then in the Button_Click, I'd create a new frmMain and show it:


If Not m_frmMain Is Nothing Then
   m_frmMain.Dispose()
   m_frmMain = Nothing
   m_frmMain = New frmMain
   m_frmMain.Show()
Else
    m_frmMain = New frmMain
    m_frmMain.Show()
End If
0 Kudos
deleted-user-yA_w_FC9FKe5
New Contributor III
Thanks for trying to help.  The form I am trying to open was created in the VBA of the MXD.  So this form is not include with the VB.Net project. 

For some reason ESRI did not see it fit to have my button controls to come in like they have from all other version jumps where VBA is allowed.

So my project does this:
1.) Create an add-in button in VB.Net that opens my form that is in the MXD and not the .net solution.

Hopefully that makes some sense.  Please tell me I can do this.  Recreating these forms in .net is going to take forever.  I have decades of code in VBA.
0 Kudos
JamesCrandall
MVP Frequent Contributor
Thanks for trying to help.  The form I am trying to open was created in the VBA of the MXD.  So this form is not include with the VB.Net project. 

For some reason ESRI did not see it fit to have my button controls to come in like they have from all other version jumps where VBA is allowed.

So my project does this:
1.) Create an add-in button in VB.Net that opens my form that is in the MXD and not the .net solution.

Hopefully that makes some sense.  Please tell me I can do this.  Recreating these forms in .net is going to take forever.  I have decades of code in VBA.



ouch.  Well, hopefully someone will jump in here and provide a solution.

That's a lot of VBA code.  Have you considered moving competely out of VBA/Add-in model and convert everything over to your own .NET assemblies?  Yes, it would be painful (it was to me too), but you will free yourself from the conditions/confines that you are finding yourself in now and in the future. 

VBA is totally gone at ArcGIS v10.1 I think.

And yes, I find that the initial attempts at deployment/distribution is a pain, but it does get better as you gain experience when things go bad.  That is if deployment issues are what caused you to stick with VBA.
0 Kudos
deleted-user-yA_w_FC9FKe5
New Contributor III
"That's a lot of VBA code. Have you considered moving competely out of VBA/Add-in model and convert everything over to your own .NET assemblies? Yes, it would be painful (it was to me too), but you will free yourself from the conditions/confines that you are finding yourself in now and in the future. "

Not sure how to even start doing this.  Can you lead me to a simple getting started example like "hello World" on the click of a button.  Not sure how I would create something in .net and then bring it into ArcGIS.
0 Kudos
JeffreyHamblin
New Contributor III
Hi Michael,

I put together a tutorial on moving a simple VBA utility (which includes a form), to a C# Add-in. It covers most of the basics:

VBA to C# Add-In Tutorial

It has screenshots, code snips and some short videos.

-Jeff H
0 Kudos