I have an Excel 2007 macro that opens up a Word document and runs a Word macro that does a mail merge. It works great in Excel 2007, but I just switched to Excel 2010 (and Word 2010 of course). The Excel code still opens the Word file, but the macros are disabled when it opens Word so it doesn't run the mail merge macro.
Even if I enable Word macros in the Trust Center Settings (I know that's not recommended) it still doesn't allow me to run the Word macro.
If I open the Word file on my own and enable the macro, it works just fine.
The Excel code to Open Word and run the macro is:
My Word code (which won't run if the Excel macro opens the file), is:
Any insight would be greatly appreciated!
Thanks.
-Strider71
Even if I enable Word macros in the Trust Center Settings (I know that's not recommended) it still doesn't allow me to run the Word macro.
If I open the Word file on my own and enable the macro, it works just fine.
The Excel code to Open Word and run the macro is:
Code:
Sub Run_Mail_Merge()
Dim wordApp As Object
Set wordApp = CreateObject("Word.Application")
wordApp.Documents.Open Filename:="D:\Form Letter.docm"
wordApp.Visible = True
wordApp.Run "!newmacros.MailMergeMacro"
End Sub
My Word code (which won't run if the Excel macro opens the file), is:
Code:
Sub MailMergeMacro()
If ActiveDocument.MailMerge.State = wdMainAndDataSource Then
ActiveDocument.MailMerge.Execute
End If
ActiveDocument.SaveAs FileName:="Completed Letter.doc",
FileFormat:=wdFormatDocument, LockComments:=False, Password:="",AddToRecentFiles:= True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub
Any insight would be greatly appreciated!
Thanks.
-Strider71