GEOG 5224P Project 1

Basics of ArcView Customization

by Tom Wells -  January 2004

Fig.1 - Input

Fig.2 - Output

Fig.3 - Customization

Comments 

Sources

The first programming project introduces the student to programming in the ArcMap VBA (Visual Basic for Applications) Windows based programming environment.  VBA is a popular Microsoft® Windows "macro" programming language because it is included with the very popular Microsoft Office Suite (all versions since Office 97).  AutoCAD®, the most popular PC based professional CAD program, also supports VBA based customization / add-ons.  Many other windows programs can be customized and extended via VBA.  

The premise of the lesson is that the intended custom application users are building visitors who may know little about Geographic Information Systems (GIS).  Therefore, the ArcMap version 8.3 user interface is customized and simplified via the removal of the more advanced buttons on three toolbars.  VBA code is added to the Lesson1.mxd (ArcMap document) load event that prompts the user for his or her name and then welcomes the user to the application.

The first two figures capture the VBA code in action and both figures show the customized user interface with some supplied data.  The third figure shows the user interface "Customization" dialog form's Toolbars tab.


VBA Program Code

The following VBA is executed automatically when Lesson1.mxd, a newly created ArcMap document, is loaded.  The code is executed because it was saved in the document's private "OpenDocument" event which, as the name implies, executes automatically when the document is loaded into ArcMap.

 


Private Function MxDocument_OpenDocument() As Boolean

Dim strUserName As String
strUserName = InputBox("Please enter your name:", _
"What's your name?", "your name here")
MsgBox "Hi, " & strUserName & "! This is the Penn " & _
"State World Campus GIS Demonstration Project." & _
vbCrLf & vbCrLf & " Please " & _
"explore this exciting map of the United States!", _
vbOKOnly, "Hello"

End Function

The above code is very similar to the supplied VBA code.  I took the liberty of modifying the code to better fit a modest display screen. The above code utilizes "_" continuation characters to permit a VBA statement to occupy multiple lines of code in the VBA editor.   The code also includes Visual Basic Carriage Return / Line Feed character constants (vbCrLf) to break the MsgBox output onto separate lines as shown in Figure 2.  The first figure shows the InputBox in action as follows:

 
Figure 1: ArcMap 8.3 Application Screen Shot with Lesson1.mdx just loaded to trigger the VBA code shown above.  The InputBox is requesting user input.  The "your name here" that is initially displayed has been replaced with my name.


Program Operation

Figure 1 & 2 show the lesson 1 exercise in action. The VBA code shown above prompts the user twice.  The InputBox generated "What's your name?" dialog box is shown above and the MsgBox "Hello" dialog box is shown below.


 
Figure 2: ArcMap 8.3 Application Screen Shot with Lesson1.mdx in action.  The MsgBox is displaying the user input along with a hard coded message.


User Interface Customization

Most Microsoft Windows applications utilize both a main menu-bar and one or more tool-bars with multiple buttons each.  ArcMap 8.3 ships with so many tool bars, that the operator probably doesn't want to use them all at once because they would take up too much valuable screen space.  The customized graphical user interface shown in both Figure 1 & 2 only utilizes three toolbars plus the "Main Menu" as indicated in Figure 3.  Note how all of the available tool bars do not fit on the "Customize" dialog form.  The "Spatial Analyst" toolbar is one of multiple add-ins available from ESRI (the author of ArcView / ArcMap).  The "Locus EIM Toolbar" add-in was written by Dr. Todd Pierce of Locus Technologies, my part-time employer.

The standard ArcMap 8.3 user interface has been simplified by the removal of the more advanced options.  Buttons have been removed from all three toolbars and the Main Menu has been simplified too.


 

Figure 3:

ArcMap 8.3 GUI customization dialog box.


Comments

This course does not assume that the student has any previous programming experience.  However, we were also warned that many students find this course too challenging and consequently they drop-out.  I believe that Lesson 1 / Project 1 would be a significant challenge to a student with no programming experience.  The concise explanation of programming with objects most interesting.



Sources


GEOG 5224P Lesson 1, https://cms.psu.edu, Accessed January 2004

GEOG 5224P CD-R, WCGIS\Lesson1_2_3\ Dataset


Go To the
Top of Page