Word VBA - Intro
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.
- The first steps
- Variables and screen output/input
- Checking variable contents
- Loops (Part 1)
- Loops (Part 2)
- Procedures and Functions
- Document Manipulation
- Optimising Your Code
- The Quick Access Toolbar
- User Forms (Part 1)
- User Forms (Part 2) - to follow in December
- User Forms (Part 3) - to follow in December
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.