Microsoft Word Add-ins/Plugin a complete reference

Microsoft Word Add-ins/Plugin a complete reference

Addin

A distributed file which can be installed and works based on plug and play concept. The addin contains pre-compiled code with set of features which can be executed once Addin is installed or attached in Word Applications. In this article we will learn how to create a Word Addin step by step:

Prerequisites

  1. Word 2013 or above

Step 1: open a blank word document and save as and name it “myTestAddin” as shown below (Select “Word Macro-Enabled Document” from Save as type dropdown)

Once you save, “myTestAddin” adds the extension “.docm” and file name turns as “mytestAddin.docm

Step 2: press ALT + F11 or navigate Developer ribbon tab and click on Visual Studio button as shown below:

It will open Visual Basic IDE where you can write you code as shown below:

Step 3: Insert a code Module

  • Navigate Insert menu (refer below screenshot)
  • Select Module

A blank module will be inserted with “Module1” name. Each module has its own extension which can be identified by “.bas“:

Step 4: Write a simple code to say Hi by putting this code ins Code area:

Public Sub SayHi()
    MsgBox "Hi there this is my first Addin"
End Sub

Step 5: Navigate back to Word document and do followings:

  • Navigate File Menu (figure 1.1)
  • Select Options
  • Select Customize Ribbon from Word Options dialog (refer figure 1.2 point (1))
  • Select the last tab under Main Tabs List (refer figure 1.2 point (2))
  • Click on New Tab button (refer figure 1.2 point (3))
  • A new tab will be inserted at the end
  • Click on Rename… button (refer figure 1.2 point (4))
  • A popup prompts asking name type the name you want
  • Next Add a group by clicking New Group button (refer figure 1.2 point (5))
  • Click on Rename… button (refer figure 1.2 point (6))
  • A popup prompts asking name type the name you want also you can choose an icon to be displayed on it
figure 1.1
figure 1.2

Step 5: Attach macro

  • Select Macros from Choose commands from dropdown (refer figure 1.3)
  • All available macros would be visible under list (refer figure 1.3 command (1))
  • Select SayHi macro name that we have written in our VB Code Editor (refer figure 1.3 command (2))
  • Select Group which you have created above (refer figure 1.3 command (3))
  • Click on Add >> button to attach macro on the group (refer figure 1.3 command (4))
  • Click Rename… button to rename your button (refer figure 1.3 command (5))
  • Say OK
figure 1.3

The output should look like below:

Click on Smiley button labeled as SayHi and it will execute the code written behind saying “Hi there this is my first Addin” as shown below:

Step 6: SaveAs your file as “Word Macro-Enabled Template” which will create a “.dotm” extension. I am changing the name of my Addin as “VBAOVERALL_Addin” you can choose whatever you want, upon selecting template from Save as type by default Word will take default path of templates “C:\Users\vbaoverall\Documents\Custom Office Templates” on your machine so remember it and say OK:

Step 7: test your job

  • Close the Word application if already opened and Reopen a fresh Word application
  • By default it might open with a blank document if so close the document
  • If you notice everything is closed but still your created Tab “VBAOVERALL Addin” and Smiley button is available.
  • If you click on Smiley button you will encounter an error saying macro cann’t be found it shows that your addin is not attached yet

Step 8: Attach or install your addin

  • Select Developer Ribbon tab
  • Click on Word Add-ins button under Add-ins group (refer figure 1.4)
  • Template and Add-ins dialog appears (refer figure 1.5)
  • Click on Add button under Global templates and add-ins
  • A file explorer will open asking to choose your template
  • Locate the path where you have saved your template
  • Click on template and it will be added under Global template and add-ins list as shown in figure 1.6 make sure it is check to true
  • Click OK
figure 1.4
figure 1.5
figure 1.6

Step 9: Verify your job

  1. Navigate “VBAOVERALL Addin” tab
  2. Click on Smiley button
  3. Wow it show your message which you wrote code behind

Please leave your comments or queries under comment section also please do subscribe to out blogs to keep your self upto date.

Leave a Reply

Your email address will not be published.