The idea behind this Add-in is that as programmers we are doing the same tasks over and over again, like writing of an “
if else” or “
try catch” blocks.
The main target of this Add-in is to release us from these tedious assignments and to concentrate on the real programming challenges. Using this Add-in you will be able to determine for your self what kind of block codes you want to create in a quick mode, and the shortcuts to activate each block.
The Add-in works in a very simple way:
All you have to do is to decide about the blocks you wish to crate in quick mode, for example:
and then, decide what code you need to type for this block to appear on the screen, I decided “
if” (big surprise). After typing the specific code all you have to do is to click the designated toolbar button, or user keyboard shortcut you have selected for it (the preferred way).
After the block is written to the screen, you still need to use the mouse to navigate to the first place you want to modify – the
() area of this example. To save this “hard” work the Add-in giving us the option to decide where the cursor will go after the code block
Just write down:
“@SELECTION@” in the designated area, and when the code is generated, this area will be selected. All you have to do is to write down your code.
The template will look like that:
How Does it Work?
The templates are saved in XML file called AutoCompleteINI.xml. The file exists in both binary.zip and Custom_Auto_Complete_src.zip. It contains the following elements:
This tag will contain the current user working on the code – you can edit the user name by using the configuration form included in the Add-in
Tags that can be inserted into the block and the Add-in will automatically change them in the code generating process, for example: the
[VAR:USERNAME] tag will be replaced with the
This tag will contain all the code blocks (called templates) that exist in the current machine.
Template – This tag contains the information for specific code block. Each block (template) contains a TName property which uniquely identifies the block and the block itself separated into lines.
NOTE: To read information from the XML file I added customized ActiveX DLL that wraps the standard XML library. The code for this ActiveX is not added here and it is not necessary, I am sure that many people will be able to read the XML better then I did, but it still does the job.
Here is a code example of XML reading in this Add-in
information from XML file
Public Function intialize() As Boolean
Dim sIniFile As String
Dim xmlFile As New CXMLParser
Dim xmlElem As CXMLElement
sIniFile = gApp.Path & "\AutoCompleteINI.xml"
m_sUserName = xmlFile.getElementPropertyValue("CPPAddIn\CurrentUser",
logIt "intialize", "Initialization Complete Successfuly"
When we write a keyword for a specific template, the code extracts the last word we typed and search the template in a collection.
We do not have to type the full name of the template we want to generate, we can write the beginning of the word and the Add-in will open another window showing all the existing templates and the closest match will be selected. All we need to do now is to press Enter or double click the requested template.
Add Your Own Code/Comment Blocks
I forgot to add this important part when I published the article so it's about time.
To add you own template you can edit the AutoCompleteINI.xml file by your self. It is very simple but it is not the goal of this Add-in.
For the purpose of editing and adding new blocks (templates) you have the second button of the Add-in. You can see the screen shot of the configuration screen at the top of the article. To add new block for quick access, all you have to do is right click on the tree on the left, and choose add template. You will be prompted to insert you shortcut key, and when you press ok, you will see the new entry in the bottom of the tree, just left click it and use the right bottom text area to write your code block.
You can also delete your template by the same context menu.
Using the Add-in
To open the VB project you need to register the XMLParser.dll file. I included reg.bat file to help you do it without any typing.
To install the binary and use it under Visual C++ 6 please read the Readme.txt file added in both zip files
The code was tested under Windows2000/XP only and it may work under windows 98 but who knows for sure…
Last Word for Now
This Add-in is a part of a larger suite for MSDev. I wrote it for the usage of my company and I got some good reviews.
I decided to publish this part because it is my first article ever submitted and I hope that after receiving emails on all the bugs I have on this little part and improvement suggestions I will be able to release the rest of the code for you all to use.
I used VB although I am a C++ programmer because it is very easy to write simple Add-ins with it. In C++ there is too just much overhead for this kind of application.
Next to Be Published
- Class Wizard that include members, methods, base classes, namespace, operators and more
- A tool that captures all the
and enable the user to send them to the outlook as tasks