Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing Macros with VBA/Script

Status
Not open for further replies.

cfjdugan

MIS
Aug 16, 2002
7
GB
Hi Folks,

Is it possible to edit an existing Word macro (contained in the Normal.dot) using VBA/VBScript rather than manually as I have about 110 computers to update? I can't find a way to do this after looking at the help pages within the VB editor or most other places I look. I can find plenty of examples of editing Autotext entries but nothing on Macros.

We are moving from locally saved templates to server based but I need to update the paths to the templates on the existing macros on each machine first.

The existing code for each Macro is this:

Sub Letter()
'
' Letter Macro
'
Documents.Add Template:= _
"C:\Program Files\Microsoft Office\Templates\LtrBlank.dot", NewTemplate:= _
False
End Sub

The path to the file just needs to be updated to point to a server location via a mapped drive.

If anyone has any pointers or code examples I'd be greatful :)

--
Chris
 
I think you will need a reference to Microsoft Visual Basic for Extensibility Library (VBE).

There are additional security concerns on a per computer basis - a setting that allows code access to the vb editor (or something similar).

Hope this helps
 
Hi,

thanks for that, after reading your pointer I found the following:


How To Create and Call an Excel Macro Programmatically from VB

Just what the doctor ordered :) Built for Excel but should be able to modify it for Word and set it up as an AutoExec macro and send it out as an e-mail attachment, or incorporate the VB code into a startup script.

The security setting is in the macro security settings and I should be able to (temporarily) over-ride that with a GPO or other script to set the appropriate registry setting.

--
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top