Friday, October 23, 2009

Intro to Customizing ArcGIS Desktop, Toolbars, and Normal.mxt

While attempting to build a (forthcoming) custom tool for my ArcGIS environment, I encountered a problem: I cannot save my new custom toolbar to Normal.mxt. Every time I close and re-open ArcMap, the toolbar does not return.

I am attempting to construct a toolbar to use in my default environment, so naturally I begin working in a blank (Untitled) .mxd document. This is probably a problem: it seems that Normal.mxt is updated when the .mxd is saved or closed, so I'll start by creating a local project so the "save" command can be called.

The following is my version of a walkthrough that discusses how to properly add a toolbar to the Normal.mxt template.
  • Start ArcMap with a new/blank document
  • Save this document anywhere - location is not important. It can be deleted later. Again, I'm assuming that a saved document allows the .mxt file to be saved, thus edits can be applied, though this is just a hypothesis.
  • Open the Customize dialog (from Tools :: Customize, or double click in a gray area beside a docked toolbar)
  • Choose New to create a new, blank toolbar
  • Give the new toolbar a name, and be sure to change the "Save in" option to Normal.mxt.
    ( Normal.mxt is the default, base template that ArcMap uses to define the which toolbars are included in its operating interface. When a new/blank document is launched, Normal.mxt is called to define which buttons and toolbars go where. Over time it is nice to change this around to suit individual needs)
  • The new, blank toolbar is added to the project
  • Add some buttons/tools/commands to the toolbar by navigating to the Commands tab from the Customize dialog. There are many provided by ESRI, sorted into Categories (the pane on the left) and the actual commands (buttons) are located in the Commands list to the right. Select the one you want and drag it carefully to the new toolbar, or to any other toolbar. Again, be sure to "Save in" Normal.mxt
  • To add customized buttons from which you can run your own Visual Basic code, scroll all the way to the bottom of the Categories list and select [UIControls].
  • Press the New UIControl... button
  • Choose from one of the control types - UIButtonControl will make a button that will run some code that will be programmed later - and press Create
  • Rename the control to something that will be recognized easily, and drag the control to the new toolbar
  • Change the button's icon/picture by right clicking on the button (with the Customize dialog still launched) and choose an icon from the "Change Button Image" sub-menu.A custom .bmp file can be used as the image by choosing Browse from this menu
  • To begin editing code, right click on a button (command) and choose View Source to launch the Visual Basic Editor (shortcut key Alt+F11)
  • Now close the Customize dialog box and save the otherwise blank ArcMap document. From here the new toolbar and its tools should be saved in Normal.mxt.
  • Just for the sake of argument, drag the toolbar to the top of the ArcMap window to dock it. (This really shouldn't be necessary though.)

  • Save the document again
  • Open the Customize dialog again and change the "Save in" option from Normal.mxt to the alternative choice which will be the name of the .mxd. If the toolbar is still present, the Normal.mxt template has been successfully altered with the addition of the new toolbar. Change the "Save in" option back to Normal.mxt and continue alterations if necessary.
See also:
ESRI Article: Save Custom Toolbar Configuration
My Normal.mxt

No comments: