Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Enable Word Template Macro from Excel

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
Ian Ian is offline
external usenet poster
 
Posts: 238
Default Enable Word Template Macro from Excel

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

--
Ian
--
"L Smith" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel template has spelling "grey" will not work. How to enable? Shawn Excel Discussion (Misc queries) 1 January 21st 10 07:29 PM
How do I enable macro use in excel 2007 Tith Excel Discussion (Misc queries) 2 May 11th 09 05:27 PM
How can I link between a Word template and an Excel template Josh Excel Discussion (Misc queries) 0 April 1st 08 12:36 AM
export excel data to a word template using a macro Ross1 Excel Programming 1 March 25th 05 04:31 AM
Automatically enable macros for particular template Bryan Linton Excel Programming 1 February 2nd 05 10:31 PM


All times are GMT +1. The time now is 07:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"