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: Dushura Dagrel
Country: Honduras
Language: English (Spanish)
Genre: Music
Published (Last): 22 January 2017
Pages: 214
PDF File Size: 12.60 Mb
ePub File Size: 6.81 Mb
ISBN: 627-7-42825-730-5
Downloads: 66236
Price: Free* [*Free Regsitration Required]
Uploader: Kazilabar

Arobjects might ask this after installing ArcGIS They are authored in. 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. You need to pick the option that best suits your application. The VBA sample for this exercise is a simple form that reads the selected county on the map and displays its information on the form. If the ArcGIS templates do not show up when creating a new project, make sure you have.

Because this article is intended to demonstrate the ease of converting VBA code to. NET, some of the description of the project creation process is not detailed.

For more detailed information, Esri has created a very good example. Search the online help for the article “Walkthrough: Migrating VB6 to VB. Side-by-side view of VBA form and.

It must be manually re-created. However, as demonstrated in the next section, the code is reusable and easily upgraded.

Aecobjects is one other major piece: This is where the work is done in the VBA sample, and this code needs to be copied and converted. 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.

New to ArcMap VBA | GeoNet

Copy the subroutine and paste it into the newly created form in the add-in project. In this example, open the included file called Form1. Right-click the form created in Visual Studio and pick View Code. Paste the subroutine in the code behind. Qrcobjects the code is pasted, several errors will show up.


Most of these will go away once the right references are added. This example requires two references. Just adding the references won’t fix the problems because the code that was copied worked in VBA because the VBA editor understood the shorter names for ArcObjects. This is easily fixed by adding import statements at the top of the code. Doing this lets Visual Studio use the shorter names also.

At the very top of the code for the form, above the public class, add three import statements Figure 4. The next fix addresses something that happens a lot when converting code from VBA to. To set the text to the labels in VBA, the property is called Caption. NET, to set the text to the label, the property is called Text. This is easy enough to fix.

ArcGIS Desktop Help – Sample VBA code

Arcobjcts way would be to simply replace the word caption with the word text. Another way demonstrates one of the benefits of using the Visual Studio environment.

Go zrcobjects the error lblCountyName. Place the cursor at the end of the word lblCountyName and press the period key.

This brings up Intelli-Sense and shows all the properties available to set on the label. Scroll down and pick the word Text. Side-by-side view of VBA code and.

While it might have been easier to just retype Caption to Text, if the correct property is not known, this is a very useful feature. Vb changing the labels from caption to text, only one error remains. This is really the only major error in converting the code.

An error is triggered by ThisDocument.

To fix this error, change ThisDocument to My. When all errors are fixed, Visual Studio displays the arcobjecte error “‘pFCursor’ is passed vha it is assigned. All the code has been converted for the form. Figure 5 shows the code before and after. Not much has changed in the conversion between VBA and the add-in. However, note that when pasting the code, Visual Studio did convert some code automatically. In this example, it removed the word Set and it put parentheses around the command pFLayer.

There is one last thing to do before the code is ready to use.

When the add-in project was created, the Button checkbox was checked. This added a command button to the project. From the Solution Explorer, right-click FormButton. This opens the code for the button. In the OnClick event, add the following two lines:. That’s it for converting the code. Now go to the Build menu and build the project. After the project is built, the files are bundled as an add-in and automatically installed in ArcMap.


It contains counties and states for the entire United States. Go to the Customize menu and pick Add-In Manager Figure 6verify the add-in arcovjects, and close the dialog box. Go to the Customize menu and pick Customize Mode. In the Customize dialog box, click the Commands tab Figure 7.

Choose Add-In Controls from Categories the category that was defined when creating the add-in. Drag the My Form Button from Commands and drop it on any arcobjecys.

How To: Create a new graticule using VBA and ArcObjects

Close the Customize dialog box. In ArcMap, select a county on the map. Click the button to show the county form that was just dragged to the toolbar. This opens the County Info dialog racobjects.

With a county selected, click the Read Data button on the dialog box. This will read the selected county information and display it on the form.

Click the Close button to close the County Info dialog box. This code could be improved. The add-in model has many more options. For more information on these topics, arcbojects the online help for ArcObjects for. The Esri online help is very useful. In arclbjects, even though VBA is gone, with a little refactoring and a good bit of copying and pasting, existing VBA code can be reused in the new. He can be contacted at cgallant ljbinc. This article as a PDF. First wizard screen encountered when creating an add-in.

Second wizard screen for creating command button. Code view with errors and import statements. The Add-In Manager dialog box. The Customize dialog box.