How To: Create a new graticule using VBA and ArcObjects. Summary. This article shows how to create a new graticule and set its properties in ArcMap. You might ask this after installing ArcGIS With the release of ArcMap 10, Visual Basic for Applications (VBA) is on the way out. As the online help article. Customizing and developing with ArcGIS > Writing macros using VBA the ArcGIS Desktop Developer Guide, or from Exploring ArcObjects.

Author: Kazranris Femi
Country: Pakistan
Language: English (Spanish)
Genre: Personal Growth
Published (Last): 15 April 2010
Pages: 137
PDF File Size: 17.40 Mb
ePub File Size: 15.4 Mb
ISBN: 796-8-36645-304-7
Downloads: 98496
Price: Free* [*Free Regsitration Required]
Uploader: Ter

Because this article is intended to demonstrate the ease of converting VBA code to. For more detailed information, Esri has created a very good example. At the very top of the code for the form, above the public class, add three import statements Figure 4. The VBA sample for this arcobhects is a simple form that reads the selected county on the map and displays its information on the form.

It must be manually re-created. After arcobjectts project is built, the files are bundled as an add-in and automatically installed in ArcMap.

Right-click the form created in Visual Studio and pick View Code. Paste arvobjects subroutine in the code behind. This example requires two references. They provide a declaratively based framework for creating a collection of customizations that can be conveniently packaged in a single compressed file that is easily shared.

Most of these will go away once the right references are added. This brings up Intelli-Sense and shows all the properties available to set on the label.


Go to the Customize menu and pick Customize Mode. Now go to the Build menu and build the project.

How To: Create a new graticule using VBA and ArcObjects

That’s it for converting the code. However, as demonstrated in the next section, the code is reusable and easily upgraded. Not much has changed in the conversion between VBA and the add-in. An error is triggered by ThisDocument. In the OnClick event, add the following two lines:. This code could be improved. In this example, open the included file called Form1. The Add-In Manager dialog box. Side-by-side view of VBA form and.

One way would be to simply replace the word caption with the word text. Go to the Customize menu and pick Add-In Manager Figure 6verify the add-in loaded, and close the dialog box. In this example, it removed the word Set and it put parentheses around the command pFLayer.

This added a command button to the project. This is easily fixed by adding import statements at the top of the code. With a county selected, click the Read Data button on the dialog box. Place the cursor at the end of the word lblCountyName and press the period key. In ArcMap, select a county on the map. When the code is pasted, several errors will show up. Go to the error lblCountyName. NET, to set the text to the label, the property is called Text.

However, note that when pasting the code, Visual Studio did convert some code automatically. After changing the labels from caption to text, only one error remains. First wizard screen encountered when creating an add-in.


ArcObjects SDK for VBA

To set the text to the labels in VBA, the property is called Caption. There is one other major piece: Figure 5 shows the code before and after. This is really the only major error in converting the code. To fix this error, change ThisDocument vvba My. The add-in model has many more options.

How To: Create a new graticule using VBA and ArcObjects

This opens the County Info dialog box. He can be contacted at cgallant ljbinc. This will read the selected county information and display it on the form. It contains counties and states for the entire United States.

When the add-in project was created, the Button checkbox was checked. Doing this lets Visual Studio use the shorter names also. Click the Close button to close the County Info dialog box. They are authored in. Migrating VB6 to VB.

The next fix addresses something that happens a lot when converting code from Agcobjects to. An easy way to do this is to export the form to be upgraded out of the VBA editor and open the exported file with the. Click the button to show the county form that was just dragged to the toolbar. Side-by-side view of VBA code and.