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.
|Published (Last):||13 May 2018|
|PDF File Size:||16.84 Mb|
|ePub File Size:||7.72 Mb|
|Price:||Free* [*Free Regsitration Required]|
However, note that when pasting the code, Visual Studio did convert some code automatically. Figure 5 shows the code before and after. For more information on these topics, see the online help for ArcObjects for. From the Solution Explorer, right-click FormButton. That’s it for converting the code.
This code could be improved. At the very top of the code for the form, above the public class, add three import statements Figure 4. When the add-in project was created, the Button checkbox was checked. In this example, it removed the word Set and it put parentheses around the command pFLayer.
Scroll down and pick the word Text. It must be manually re-created. In the Customize dialog box, click the Commands tab Figure 7. He can be contacted at cgallant ljbinc. NET, to set the text to the label, the property arcobjecrs called Text. Go to the Customize menu and pick Add-In Manager Figure 6verify the add-in loaded, and close the dialog box. Another way demonstrates one of the arcobjscts of using the Visual Studio environment.
ArcObjects SDK for VBA
In conclusion, 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. In this example, open the included file called Form1. This is really the only major error in converting the code. While it might have been easier to just retype Caption to Text, if the correct property is not known, this is arcobjecys very useful feature. Search the online help for the article “Walkthrough: Code view arcobkects errors and import statements.
First wizard screen encountered when creating an add-in. The Esri online help is very useful.
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. For more detailed information, Esri has created a very good example. Right-click the form created in Visual Studio and pick View Code. Doing this lets Visual Studio use the aarcobjects names also.
Close the Customize dialog box.
How To: Create a new graticule using VBA and ArcObjects
After changing the labels from caption to text, only one error remains. This article as a PDF. There is one last thing to do before the code is ready to use.
Go to the error lblCountyName. This example requires two references. With a county selected, click the Read Data arcobjcets on the dialog box. There is one other major piece: However, as demonstrated in the next section, the code is reusable and easily upgraded. Copy the subroutine and paste it into the newly created form in the add-in project.
When all errors are fixed, Visual Studio displays the warning error “‘pFCursor’ is passed before it is assigned. 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.
Second wizard screen for creating command button. Click the button to show the county form that was just dragged to the toolbar. Side-by-side view of VBA form and. All the code has been converted for the form. In ArcMap, select a county on the map. This arcoobjects easy enough to fix.
Just adding the references won’t fix the problems because the code arxobjects was copied worked in VBA because the VBA editor understood the shorter names for ArcObjects.
The next fix addresses something that happens a lot when arcobejcts code from VBA to. To set the text to the labels in VBA, the property is called Caption. This is where the work is done in the VBA sample, and this code needs to be copied and converted. The Customize dialog box.
This is easily fixed by adding import statements at the top of the code.