Cannot get field values

C

Crazy Macros

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
 
D

Doug Robbins - Word MVP

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.

--
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
 
C

Crazy Macros

Doug,

It doesn't work. Is there a way to debug this. I can't even use
MsgBox. Please advice.
 
D

Doug Robbins - Word MVP

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.

--
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
 
D

Doug Robbins - Word MVP

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?

--
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top