Possibility to identify a mailmerge docume (Word2k)

I'm having VBA-code, that should only run in "normal" documents, but not in documents created by mailmerging. Is there any way to identify such a document? (The newly created document when a mailmerge with a new document as destination is executed.)

Re: Possibility to identify a mailmerge docume (Word2k)

<P ID="edit" class=small>(Edited by jscher2000 on 09-Sep-03 10:32. On second thought...)</P>Good one! What I find helpful in tracking down these properties is to pop up the object browser (F2) and search for a term I think will help, in this case merge since I thought perhaps the existence of a data document might flag a document as a merge document. Scrolling down the list, I saw MailMergeDataSource. Highlighted that and hit F1. I clicked up the object tree in help to the MailMerge object and in the first paragrah, it mentions a State property. The State property help looks like the answer:

<UL>Returns the current state of a mail merge operation. Read-only WdMailMergeState.

WdMailMergeState can be one of these WdMailMergeState constants.
wdDataSource
wdMainAndDataSource
wdMainAndHeader
wdMainAndSourceAndHeader
wdMainDocumentOnly
wdNormalDocument[/list]In other words <img src=/S/smile.gif border=0 alt=smile width=15 height=15> , this could be your first attempt:

if not activedocument.MailMerge.State =wdNormalDocument then exit sub

Added: That should work in the merge document itself. But if you don't want it to work in the wdNormalDocument that (presumably) results from the merge, I think you'll have to dig around a bit more. Perhaps you will need to insert some kind of marker in the document so you know one when you see it.

Re: Possibility to identify a mailmerge docume (Word2k)

Hi Jefferson

Thanks for the reply. And that's exactly what I did before posting (Sorry my description was probably to short.). I looked for available properties in the object browser - but unfortunately MailMerge.State will only return wdNormalDocument for the document type. Since there are other non-mailmerge documents which were generated by the same template, this doesn't work.
In Word XP I might catch one of the mailmerge events and mark the newly created document. But in Word 2k no mailmerge events exist :-/

Right now, I've run out of ideas - but it keeps bothering me. If you have another idea, I would really appreciate it.

Re: Possibility to identify a mailmerge docume (Word2k)

I did some further testing, document variables are copied as well, but I think I found one difference now: Bookmarks are not copied (except bookmarks placed in a header or footer.) Since the original template already contains bookmarks, I seem to have found a solution for the problem. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>