Word VBA - Intro

Word VBA - Intro
Photo by Florian Olivo / Unsplash
Mike Mee

This is an intro to what will be a series of 18 (!!) separate guides on VBA Macros to use in Microsoft Word.

I originally published them in the ISTC magazine, Communicator and they were spread over a few years/issues. It covered the process from the early baby steps through to using arrays in your VBA code to speed up functionality.

The same VBA code can be used, near enough, within Excel, PowerPoint and Outlook. However, the collections and properties will change - e.g. instead of paragraphs, you'd be interacting with worksheets, pages and emails.

Differences between VBA and Office Scripts

Note that VBA is not the same as the newer Office Scripts as released for Office 365.

  • VBA is a proper BASIC-based language that lives behind your Word documents et al.
  • Office Scripts were created so that those using Teams, and the online versions of Office 365, can still perform automations without setting off the "You have macros! How very dare you!" warnings that are generated when your simple macros are mistaken for an attempt to take over the world.

Available Articles

Note: as this is a members website, only the first article will be available to non-members.

  1. The first steps
  2. Variables and screen output/input
  3. Checking variable contents
  4. Loops (Part 1)
  5. Loops (Part 2)
  6. Procedures and Functions
  7. Document Manipulation
  8. Optimising Your Code
  9. <More to follow>

Plug!

I also have a Word add-in that contains a lot of functionality for power Word users which I developed over a number of years too. It can be found at www.mikestoolbox.co.uk. The full source code to this add-in is also available on the same website along with the PDFs of the original Communicator articles.

There is also an Excel library on my site which contains a set useful VBA code and functions, especially for those of you that like to dabble in macros whilst in your own spreadsheets.