Visual Basic Concepts
Once an add-in is registered in the Windows system registry, you must set up a reference to it before it appears in the Add-In Manager and becomes useable to Visual Basic. There are two ways to do this:
[Add-Ins32]
section of the Vbaddin.ini file.You can create the entry any way you like, but the most often used programmatic method is through the Windows API function WritePrivateProfileString. Here is example code demonstrating how to do this (the function's arguments are described after the example):
Declare Function WritePrivateProfileString& Lib _
"kernel32" Alias "WritePrivateProfileStringA" _
(ByVal AppName$, ByVal KeyName$, ByVal _
keydefault$, ByVal FileName$)
Sub AddToINI()
Dim rc As Long
rc = WritePrivateProfileString("Add-Ins32", _
"MyAddInProject.MyAddInClass", "0", _
"VBADDIN.INI")
MsgBox "Add-in is now entered in VBADDIN.INI file."
End Sub
The first argument of WritePrivateProfileString
is the name of the section of the .ini file in which to place the information. In the case of add-ins, this should always be "Add-Ins32"
.
The second argument is the programmatic ID, which consists of the names of your project and class, separated by a dot. The project name is entered in the Properties dialog box in the Projects menu. The class name is entered in the Name property of the class module. (Note that the name of the module plays no part in this.)
The third argument is a value for the add-in’s entry in the Vbaddin.ini file — in this case, 0. Setting the entry to 1 means that the add-in will be loaded (that is, selected in the Add-In Manager) at IDE startup. Setting the entry to 0 means that it will not be loaded at IDE startup, but it will be included in the list of available add-ins in the Add-In Manager.
The fourth and final argument is the name of the file to apply the setting to. In the case of add-ins, this is the Vbaddin.ini file.
While the name format of project.class (its programmatic ID) looks fine in the .ini file, it might be a bit confusing for users seeing it in the Add-In Manager’s add-in list. You can change this to a more friendly name.
To change the add-in name that appears in the Add-In Manager
The text you enter will be saved along with the add-in, so users will see the same description in their Add-In Manager once it’s installed on their system.
Another (and much easier) way to create a reference to an add-in is with the Add-In designer. To do this:
Once the above information is filled out and you compile your project, your new add-in will appear in the Add-In Manager's list of available add-ins.