Excel like a finance pro.
Automate another Office app without breaking on other machines
Why an email macro works for its author and fails for everyone else — and the fix.
1What it does
Code that drives Outlook, Word or PowerPoint can find those applications two ways. EARLY binding adds a reference to a specific library version and declares `Dim app As Outlook.Application` — you get autocomplete, and a file that fails to compile on any machine with a different Office build, with an error blaming a missing reference. LATE binding declares `Dim app As Object` and creates it with `CreateObject` at run time — no autocomplete, and it runs wherever the application is installed. The professional pattern is to develop early-bound for the help, then switch to late-bound before sharing.
2The code
' Develop with EARLY binding for autocomplete, then switch. The one real cost
' of late binding: the named constants from the library no longer exist, so
' their numeric values have to be written in.
Sub LateBoundWordReport()
Dim wdApp As Object, doc As Object
Const wdAlignParagraphCenter As Long = 1 ' was a library constant
On Error Resume Next
Set wdApp = GetObject(, "Word.Application") ' reuse Word if it's open
If wdApp Is Nothing Then Set wdApp = CreateObject("Word.Application")
On Error GoTo 0
If wdApp Is Nothing Then
MsgBox "Word isn't installed on this machine.", vbExclamation
Exit Sub
End If
wdApp.Visible = True
Set doc = wdApp.Documents.Add
With doc.Paragraphs(1).Range
.Text = "Monthly report — " & Format(Date, "mmmm yyyy")
.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
' Paste a chart or range from Excel here, then release the objects.
Set doc = Nothing
Set wdApp = Nothing
End SubPaste into the Visual Basic Editor (Alt + F11 → Insert → Module), then run and save as macro-enabled (.xlsm).
New to macros? Set up in 5 minutes▾
- 1
Don't see the Developer tab in the ribbon?
You don't strictly need it — Alt + F11 opens the editor directly — but it makes running macros easier.- Windows: File → Options → Customize Ribbon → tick Developer in the right-hand list → OK.
- Mac: Excel → Preferences → Ribbon & Toolbar → tick Developer → Save.
- 2
Paste in the code
Press Alt + F11 to open the Visual Basic editor, then Insert → Module and paste the snippet's code into the blank window. Close it with Alt + Q. - 3
Run it
Press Alt + F8, pick the macro's name, and click Run — that's it. (Pasted a custom function instead? Just type it into a cell like any built-in:=GrossMargin(B2, B3).) - 4
Keep the macro — save as .xlsm
File → Save As → Excel Macro-Enabled Workbook (.xlsm). A plain .xlsx silently drops the code when you save. - 5
Macros blocked?
Click Enable Content on the yellow bar. If you downloaded the file, you may first need to right-click it → Properties → tick Unblock → OK, then reopen.
Heads up: macros can't be undone with Ctrl + Z — save a copy before running one that changes your workbook.
3When you use it
- Make an Outlook or Word macro run on every colleague's machine.
- Reuse an already-open copy of Word or Outlook instead of launching another.
- Share a workbook with automation across mixed Office versions.
4See it in action
A simulation — press Run to perform what the macro does to a sample workbook.
| Autocomplete while writing | yes |
| Named constants (wdAlign…) | available |
| Result | Runs |
Works here, with autocomplete. Now try it on a colleague's machine.
5Pitfalls
"Compile error: Can't find project or library" on another machine, naming the wrong thing.
Fix: That's early binding meeting a different Office version. Switch to Object and CreateObject.
After switching to late binding, constants like olMailItem or wdAlignParagraphCenter are undefined.
Fix: Late binding has no library, so no constants. Declare them yourself with their numeric values.
Every run launches another invisible copy of Word, left running in the background.
Fix: Try GetObject first to reuse an open instance, and Quit or release what you created.
It works in testing and fails silently in production.
Fix: Keep Option Explicit on — late binding moves errors from compile time to run time, so undeclared names matter more.
6No-code alternatives
- Early binding, kept — Fine when every machine runs the same Office build — a single-user file, or a locked-down corporate estate.
- Power Automate — For email and document workflows that shouldn't depend on anyone's desktop Office at all.
Rather not write macros? Wauvel's free tools generate branded, formula-driven Excel for you — no VBA required.
Learn the moves here — or let Wauvel run them on your numbers.
Meet your AI CFO →One CFO-grade Excel tip a week
A short, practical email for finance operators — functions, shortcuts, and the moves that save an afternoon. Free, unsubscribe anytime.