I have set up an Mail merge document. But, I have to manually click on
View Merge Data <<A>> Button to get values. I used the following macro
code to get execute mailmerge.
If ActiveDocument.MailMerge.State = wdMainAndDataSource Then
ActiveDocument.MailMerge.Execute
End If
Maybe you need:
If ActiveDocument.MailMerge.State = wdMainAndDataSource Then
ActiveDocument.MailMerge.Destination = wdSendToNewDocument
ActiveDocument.MailMerge.Execute
End If
I am not sure where it goes if you don't specify a destination.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
>I have set up an Mail merge document. But, I have to manually click on
> View Merge Data <<A>> Button to get values. I used the following macro
[quoted text clipped - 3 lines]
> ActiveDocument.MailMerge.Execute
> End If
Crazy Macros - 19 Nov 2005 17:53 GMT
Doug,
It doesn't work. Is there a way to debug this. I can't even use
MsgBox. Please advice.
Doug Robbins - Word MVP - 19 Nov 2005 19:57 GMT
I would suggest that you first get the merge working by executing it using
the user interface rather than jumping straight in with a macro.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Doug,
>
> It doesn't work. Is there a way to debug this. I can't even use
> MsgBox. Please advice.
Crazy Macros - 21 Nov 2005 14:27 GMT
I got the merge working with UI. I need help to get it automated.
Doug Robbins - Word MVP - 21 Nov 2005 18:37 GMT
Can you get the msgbox function to work?
For example, if you run a macro with the command
msgbox "Hello World."
you should see a message box with that message in it.
You are going to have to sort that out before trying anything else.
Why do you want to automate the mailmerge? Are you trying to do it from
some other application?

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
>I got the merge working with UI. I need help to get it automated.
It doesn't work. Is there a way to debug. I can't even display MsgBox.