Can I link in external code to a Word document? I have a lot of word documents with macros (VBA-code). All with the same code. I would like the code to be run from an external source instead of from within all of those documents. That way, if I have to update the code, I only have one place where I have to do the update.
You can create a template and put it in the %APPDATA%\Microsoft\Word\STARTUP folder, this makes the template an addin and STARTUP is a trusted location which will give you fewer security issues than using macros in templates from other locations.
Then, any document can call a function in the template using Application.Run().
e.g.
In your template write following:
Function templateHello() As String
templateHello = "hello from template!"
End Function
Then, in any Word document you can write:
MsgBox Application.Run("templateHello")
Which will display a message box with "hello from template!"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With