To reopen a COM add-in for editing, double-click the .vbp (VB project) file. You need to have any
supporting files (.bas, .dsr, and .frm) in the same folder as the .vpb file, because they are all part of
the project.
If your COM add-in isn’t behaving as you expect, first unload it (from the COM Add-ins menu),
then close Access and reopen a database to see if it now works. This can fix problems that may
occur when an old version of the COM add-in code is being run instead of the current version.
If you have a database open with the COM add-in loaded, you will get a “Permission
denied” message when trying to make the DLL, because the DLL is being used. Close
any open databases and try again, and you should be able to save the modified DLL.
Next, check for duplicates of the DLL file (perhaps backup copies) that might be running instead
of the current version of the DLL. In my experience, even DLLs not located in the AddIns folder
may be run, so it’s best to have only one DLL on your computer for any given add-in (the latest
version). Backup copies can be transferred to another computer, to a disc, or zipped, to prevent
confusion.
If you find that code referencing Access objects isn’t running (with no error message, or an inap-
propriate error message, such as “No Forms Open” when you have forms open), you may need to
add a specific Access application reference to your code. Specifically, whereas COM add-in code in
an Access Designer using just Formsto reference the Access Forms collection, or Reportsto ref-
erence the Reports collection of a database, ran fine in earlier versions of Office, in Office 2007 the
Access application variable pappAccessmust be used, so the current syntax needs to be
pappAccess.Formsinstead of just Forms.
If you change the name of a toolbar button created by a COM add-in, you may see the old button
on the toolbar, instead of (or in addition to) the new one. To remove the old button, add a line of
code to the RemoveAddInCommandBarButtonfunction to remove the button, using the but-
ton’s old name instead of “Old Control Name”:
.Controls(“Old Control Name”).Delete
Create a new DLL, open an Access database to load the add-in, then unload the add-in from the
COM Add-Ins dialog to run the code with the extra line once. Close Access, reopen the VB project,
delete the line, and re-create the DLL. That should get rid of the old button.
Using a COM Add-in ........................................................................................................
Using a COM add-in is easy: just click the button it placed on the Add-Ins tab of the Ribbon, as
shown in Figure 13.8. To rename controls on any open Access forms, for example, open a form in
design view, and click the Rename Form Controls button on the Add-Ins tab. You will first get a
message asking if you want to save the original control names to their Tag property, as shown in
Figure 13.13.
WARNING WARNING
Creating COM Add-ins with Visual Basic 6 13