Enable Word Template Macro from Excel

L

L Smith

I have an Excel spreadsheet which will be used to create a Word document from
a template. I can open the template and save it as a document. However I
also want to be able to run an auto open macro contained in the template when
it opens, but it is opening with macros disabled. Even if I try to open a
template containing macros manually within Word, it does not offer the option
of enabling macros. Is this a security feature?

I would be grateful if someone could confirm whether it is possible to
enable macros in this situation, and if so how.

I am using this code (gleaned from earlier posts) :

Sub OpenTemplate()
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim wordRng As Word.Range
Dim WordPara As Word.Paragraph

On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then 'Word isn't already running
Set WordApp = CreateObject("Word.Application")
End If
On Error GoTo 0
WordApp.Visible = True
With WordApp

Documents.Add Template:= _
"C:\Documents and Settings\.... \ myfile.dot", _
NewTemplate:=False, DocumentType:=0 ',

Set WordDoc = WordApp.ActiveDocument
.ActiveDocument.SaveAs "C:\Documents and Settings\...\testsave01.doc"""

End With

Set WordDoc = Nothing
Set WordApp = Nothing

End Sub
 
I

Ian

This sounds like a Word issue, not Excel. Although you may get an answer
here, you stand more chance in a Word related NG.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top