Automating Mailmerge problem

PhilAJ

New member
Local time
Today, 09:44
Joined
Sep 13, 2009
Messages
5
Hi

I've written some code that automates a mailmerge from a form in MSacess - and it works fine...BUT...

straight after the code line

Set objWord = GetObject(stDocName, "Word.Document")

the word document opens and prompts with "Opening this document will run with the following command....etc etc " and asking for a YEs/No answer; even though my code will then the datasource and do the merge,

objWord.MailMerge.OpenDataSource Name:="C:\Temp\abc.txt", linktosource:=True
objWord.Application.Visible = True
objWord.MailMerge.Execute

Does anyone know of any way to STOP word prompting - and just continue and do the merge?

Thanks in advance

Phil
 
Here is how I do it:

Dim objWordApp as Word.Application

....

Set objWordApp = CreateObject("Word.Application")

Set objWord = objWordApp.Documents.Open(stDocName)

...

That way nothing is prompted and the mailmerge is done
 
Thanks for that Simon - it certainly works and stops the initial prompt....

BUT...

When exiting the Word document, it now says that the Normla.Dot is in use by another Application, and prompts to save it somewhere.

Any ideas...Here is the code....

Dim objWord As Word.Document
Dim objwordapp As Object

Set objwordapp = CreateObject("Word.Application")

Set objWord = objwordapp.Documents.Open(stDocName)

objWord.Application.Visible = True

objWord.MailMerge.OpenDataSource Name:=Outfile, linktosource:=True
objWord.MailMerge.Execute

objWord.Close
Set objwordapp = Nothing


Thanks Phil
 

Users who are viewing this thread

Back
Top Bottom