Creating a Visual Basic 6 Add-In
Clicking on "Designers and then on Connect(Connect.Dsr)" in the Project Window will Expose the Designer itself.
In the Properties Window, Click on Name and change it to "NumConverter", then Save it by right clicking on it in the Project Window as use "Save Connect.Dsr As" and Save it as "NumConverter" in our ConverterAddIn SubFolder. Your Project and Properties Windows should look as shown below;
The next step is to open the Designer by Right Clicking with the mouse on "NumConverter(NumConverter.Dsr)" under the Designers Folder in the Project Window. This opens up the secondary Menu and we want to select "View Object".
Now expand the Designer by Clicking on it's "Maximize Button" in the upper right hand corner of the Designer's Form to reveal all of it's Input Boxes;
Change the "Add-In Display Name" from "MyAddIn to: "Number Converter"
Change the "Add-In Description" from "Add-In Project Template" to: "Convert a Base Ten Number to Binary, Hex and Octal".
The "Application" should read "Visual Basic" and the "Application Version" should be "Visual Basic 6.0" as shown above. The Initial Load Behavior should be set to Startup and the "Addin is command-line safe" box should be left Unchecked. Close the Designer Form.
Now open the Designer's Code Window by Right Clicking on "NumConverter" under Designers in the Project Window to expose it's Menu and select "View Code";
In the General - Declarations Section you will see:
Option Explicit Public FormDisplayed As Boolean Public VBInstance As VBIDE.VBE Dim mcbMenuCommandBar As Office.CommandBarControl Dim mfrmAddIn As New frmAddIn Public WithEvents MenuHandler As CommandBarEvents ' ***Change the Dim mfrmAddIn As New frmAddin to the following;*** Dim mfrmConvert As New frmConvert
Next, in the General Section Pull Down Box select the Down Arrow
and expose the "AddinInstance - OnConnection" Sub
Remark out the "Debug.Print VBInstance.FullName line as shown. Then scroll down five lines to the
Set mcbMenuCommandBar = AddToAddInCommandBar ("My AddIn")
Change this line to read:
Set mcbMenuCommandBar = AddToAddInCommandBar ("ConverterAddIn")
Ok, we are just about done. By making the above changes we have forced VB to use an Add-In Name and Form that reflects our Number Converter as opposed to the name "MyAdd-In".
There is just a bit of house cleaning that remains however, and we will make the final Designer Code changes now. Recall previously that we made the following change to the Designers General Declarations Section:
***Change the Dim mfrmAddIn As New frmAddin to the following;*** Dim mfrmConvert As New frmConvert
Well unfortunately the term "mfrmAddIn" is still embedded in our Designer's code eight more times, and "frmAddIn" remains in one location. These occur in the following Sub Routines in addtion to the above Dim Statement:
Term | Change To: | In Subroutine | Occurrences |
mfrmAddIn | mfrmConvert | General-Show | 5 |
mfrmAddIn | mfrmConvert | General-Hide | 1 |
mfrmAddIn | mfrmConvert | AddinInstance-OnDisconnection | 2 |
frmAddIn | frmConvert | General-Show | 1 |
You can make the necessary corrections using VB's "Find and Replace" (Ctrl H) procedure under the Edit Tab of the Main Menu. (Don't worry if you miss making all of the above changes correctly, because when you try to compile the DLL, VB will let you know if there is a mismatch and then you can make the proper correction).
Ok last step, Save all of your work then click on the File Tab of the Main Menu.
Select "Make ConverterAddIn.dll.." when VB finishes making the dll, click on "Add-Ins" on the Main Menu Bar and select "Add-In Manager" to see "Number Converter" listed under the "Available Add-Ins", Highlight it and click on Loaded/Unloaded in the lower right corner, click cancel to close. Now click on "Add-Ins" (Main Menu Bar) again and "Number Converter" appears on the drop down list, select it and the Add-In opens ready to use. From here on out the "Number Converter Add-In" will be available from the Main Menu Add-Ins tab every time that VB is started.
Page 4 of 5
This article was originally published on November 20, 2002