Using ArcCatalog
Using ArcCatalog
Using ArcCatalog
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Creating and<br />
running macros<br />
<strong>ArcCatalog</strong> comes with Visual<br />
Basic for Applications. VBA is<br />
not a standalone program. It<br />
provides an integrated programming<br />
environment, the Visual<br />
Basic Editor (VBE), that lets you<br />
write a VB macro and debug<br />
and test it right away in the<br />
Catalog. A macro is a few lines<br />
of code that run in the Catalog;<br />
for example, the macro might<br />
analyze the currently selected<br />
coverage. A macro can integrate<br />
some or all of VB’s functionality,<br />
such as using message<br />
boxes for input, with the<br />
functionality available in<br />
<strong>ArcCatalog</strong>.<br />
When you create a macro,<br />
you’re creating a VB Sub<br />
procedure. The procedure’s<br />
name is the name you assign to<br />
the macro. You add code to the<br />
procedure in a Code window<br />
just as you would in VB. When<br />
you create a new macro in the<br />
Macros dialog box, precede the<br />
macro’s name with the name of<br />
the module to store it in. To<br />
save your macro as part of the<br />
Catalog, you would type a name<br />
such as<br />
“ThisDocument.myMacro”.<br />
You can also organize your<br />
macros into different modules;<br />
each module has its own Code u<br />
Creating a macro<br />
1. Click the Tools menu, point to<br />
Macros, then click Macros.<br />
2. Type the name of the macro<br />
you want to create in the<br />
Macro name text box.<br />
To place the macro in a<br />
specific location, type<br />
“ThisDocument” or the<br />
module’s name and a period<br />
(.) before the new macro’s<br />
name; otherwise, the macro<br />
will be added to the<br />
NewMacros module.<br />
3. Click Create or press Enter.<br />
The Code window appears<br />
containing a stub for the new<br />
Sub procedure.<br />
4. Type the code for the macro.<br />
5. Click the VBE File menu and<br />
click Save Project.<br />
6. Click the Close button in the<br />
VBE.<br />
4<br />
2<br />
3<br />
When you type a macro name<br />
without specifying which module to<br />
put it in, the macro is placed in the<br />
NewMacros module.<br />
248 USING ARCCATALOG