View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default MsgBox during merge

Is there a way to put code somewhere in the merge form itself

There are several ways to start a merge. What is your understanding of a
"Merge form" ?

(Identifying the last record in the merge is not a problem for me...I'm
good with that part)


How are you proposing to do it?

Regarding the INCLUDETEXT debacle, see my reply to my new fiance, Bear ;-)


FWIW, this ground was covered in the previous thread, but "You pays your
money and You takes your choice" :-)

Peter Jamieson


"Kathy Webster" wrote in message
...
Peter,

I am currently using {ASK}. I wanted a cleaner prompt, one like the
message box gives.

Since I have one master macro to initiate all merges, and only certain
merge forms that need this prompt, I need to identify on a form by form
basis which one gives the MsgBox. Is there a way to put code somewhere in
the merge form itself, telling the form to run a VBA procedure or macro at
that point in the merge process? (Identifying the last record in the
merge is not a problem for me...I'm good with that part)

Regarding the INCLUDETEXT debacle, see my reply to my new fiance, Bear ;-)

Kathy

"Peter Jamieson" wrote in message
...
If you mean that the box would pop up around the point when the very last
paragraph for the very last record is merged, the simplest way is to use
VBA to initiate the merge, e.g.

Sub MergeAndMsgbox()

With ActiveDocument.MailMerge
' set the destination you want
.Destination = wdSendToNewDocument
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
MsgBox "your message"

End Sub

Otherwise, I think you can only do this if you have information that
tells you what the last record to be merged is. For example, if your
merge data has a field called lastrecord and it is only set to "Y" in the
last record) then you could do something like the following:

{ IF { MERGEFIELD lastrecord } = "Y" "{ ASK junk "whatever message you
want to display" }" "" }

If you don't have an item that does that, then it's more difficult since
Word doesn't have a field that returns the number of records being
merged. Since IMO it would only be worth doing this for reasonably long
merges you might be able to pick an arbitrary record number that's always
going to be smaller than the actual record count and pop up your box at
that point in the merge, e.g.

{ IF { MERGESEQ } = 10000 "{ ASK junk "whatever message you want to
display" }" "" }

WIth some data sources you could probably discover the record count using
a { DATABASE } field.

As far as your other post concerning formatting within INCLUDETEXTed
documents is concerned, we went through all the possibilities I can think
of last month (did you mange to try using the character format that
macropod suggested?) - I won't respond to your post in case someone else
has a better idea, but if you want to send me the mail merge main
document, included documents etc. I will have a look at them - despam my
e-mail address by taking out the KillmapS and send them.

Peter Jamieson

"Kathy Webster" wrote in message
...
How can I code my merge document so that when the merge executes, at a
certain point in the last paragraph, a message box appears on screen to
remind the user to do something?

Blah blah blah [MsgBox: Don't forget to mail the voucher when the merge
is done!] Blah blah blah.

TIA,
Kathy