This page provides a brief introduction to
making an add-in. It is not hard to create an add-in, but complete
understanding of the VBA editor and language is far beyond this
introduction. A good reference book and much trial and error
will be necessary.
Start with an empty Excel workbook and save it with a representative
name say, my_program.xls. The xls suffix indicates that it is
a standard Excel workbook. Transfer to the VBA Editor
and view the Project Explorer.
The figure shows the Project Explorer with the
add_orie.xla and add_ormm.xla add-ins installed.
The workbooks paj_components.xls and my_program.xls
are open. There are three empty worksheets in paj_components.xls.
The ThisWorkbook module is automatically created but
it is initially empty.
Forms and modules are added by clicking on my_program.xls
line of the Explorer and choosing Insert/Form or Insert/Module.
The Project explorer is shown below with one form
and one module added. The Module name has been changed to Control
in the Properties Inspector, another window of the
VBA editor.
Double clicking on a row of the Project Inspector
will open a window showing the contents of the item. Forms are
used to create dialog boxes and modules hold VBA code.
The easiest way to add code is to copy it from
modules of other add-ins or workbooks and paste the code into
modules of my_program. To see examples open paj_components.xls
or open any of the add-ins provided in the collection.
As coding proceeds be sure to save the workbook
occasionally. The code is stored with the workbook. Workbooks
may be saved using the Save command of the VBA Editor,
but be sure the name of the workbook is selected in the Project
Explorer when the Save command is selected.
As the project is coded, you can frequently return
to Excel to test the project by running programs. Excel VBA
has several debugging tools that are very helpful. |