PDA

View Full Version : Solved: How to prevent mailmerge on document open



venht001
06-20-2008, 12:23 AM
Hello members,

Word 2003.

Is there anyway, using vba, to prevent then mailmerge error message (see attachment) beeing shown when i.e. the datasource is missing.

The reason for this is I want to be able to print the document automatically with a startup macro from the command line without this macro beeing interrupted, when the document to be printed happens to be be a mailmerge document.

Thanks,

Theo

Crooz
06-20-2008, 02:32 AM
Hi Theo,
I'm not exactly sure what you are trying to achieve. If you want to remove this error message, then you'll have to uncouple the document from the missing data source.
Click on Options... | Remove All Merge Info
Recouple the document to an existing data source and then save it.
Reactivate the macro on your 'command line'.
Hope to have been of help.
Hup Holland Hup!

venht001
06-20-2008, 04:18 AM
Well i want to use the command to automatically print a word document.
Buf if the word document happens to be a mail merge document i get the message box. As the printing is an automated process i need it to go on uninterrupted. The macro mStartUpPrintDocument handles the printing, but i don't know how to remove the datasource from the document. It seems to prompt the message before it starts the macro.

C:\Program Files\Microsoft Office\Office11\winword.exe d:\mailsca\doc.doc /mStartUpPrintDocument

Crooz
06-20-2008, 06:55 AM
Now I know what you're trying to achieve. I've been working on it for an hour or so and can not come up with a solution. This is a tough one.
If there's someone else out there that can help Theo... please. I'm curious myself to how this can be solved.
Sorry Theo, I gave it my best.

venht001
06-20-2008, 06:56 AM
Crooz, thanks for trying so far

MOS MASTER
06-22-2008, 02:45 PM
Hi & welcome to VBAX! :hi:

There's no good way of getting rid of that message. The reason is that a mailmerge document is a special document within Word and it needs it's datasource to exist.

The message you're getting is normally the second message when you open a mailmerge message. The first one is the browse for datasource dialog. (If the mailmerge document lost it's datasource)

The below code bypasses the second message by setting displayallerts property of Word to false. (on my pc I was unable to block the browse datasource dialog)


Sub OpenDocumentsWithouthWarning()
With Application
.DisplayAlerts = False
.Documents.Open (the path to your document)
.DisplayAlerts = True
End With
End Sub


HTH

venht001
06-22-2008, 11:28 PM
Thanks, for the suggestion. Altough it is no sollution for my original approach, printing via winword.exe, it gave me an idea to tackle this problem another way by using ole/vba to get the printing done.

Thanks,
Theo

MOS MASTER
06-23-2008, 09:57 AM
Hoi Theo, :hi:

Glad to see you've found a sollution for your problem.


it gave me an idea to tackle this problem another way by using ole/vba to get the printing done.


Could you share the final version of your working code so others can benefit from it?