Re: Macro to open Word and Start Mail Merge
Peter,
First you need to check that the Word object model is referenced in Excel.
You do this in Tools - References as per
1) Open the excel file and Visual Basic Editor
2) in the VB Editor, go to Tools - References
3) find and check the Microsoft Word 11.0 Object Library (or something close)
Second, your code will cause errors to occur.
When connecting to word, you need to error trap in case word is not open, or is all ready open. Thirdly, it is good practice to dimension all objects and variables before you use them.
Finally, I think your error has two sources:
1) Have not referenced the Word Object Model
2) You have to Mail Merge a Document, Not the application as in your code.
try
Dim appWd as Word.Application
Dim WdDoc as Word.Document
On Error resume next
Set appWd = Getobject (,"Word.Application")
if appWd = nothing then
Set appWd = Getobject("","Word.Application")
end if
on error goto 0
with appWd
.visible = True
set WdDoc = .documents.open Filename:="C:/30DAYLTR - Template1.doc"
WdDoc.Mailmerge ........
end with
set WdDoc = Nothing
set appWd = Nothing
Hope that helps
Wedgetail