Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
eckert1961 eckert1961 is offline
external usenet poster
 
Posts: 2
Default Email MailMerge strMailBody Question

Hello,

I am using the following code to construct the strMailBody in Word 2003 VBA
module.

strMailBody = _
vbCrLf & vbCrLf & "Hello " & _
objMerge.DataSource.DataFields("FirstName") & "," & _
vbCrLf & vbCrLf & _
"Please find attached a receipt for your recent payment." & vbCrLf &
vbCrLf & _
"Don't hesitate to contact me should you have any questions." & vbCrLf
& _
vbCrLf & _
"Regards," & vbCrLf & _
"Chris"

This works but I would like to change this to do the following. I need to
check the .DataFields(ParentsNames) to see if it's null. If it is then enter
..DataFields(FirstName). If it isn't null then I want to enter
..Datafields(ParentsNames).

What is the required syntax? Thanks in advance.

Regards,
Chris
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Email MailMerge strMailBody Question

Use:

Dim strAddressee as String
If objMerge.DataSource.DataFields("ParentsName") "" then
strAddressee = objMerge.DataSource.DataFields("ParentsName")
Else
objMerge.DataSource.DataFields("FirstName")
End if
strMailBody = _
vbCrLf & vbCrLf & "Hello " & _
strAddressee & "," & _
vbCrLf & vbCrLf & _
"Please find attached a receipt for your recent payment." & vbCrLf &
vbCrLf & _
"Don't hesitate to contact me should you have any questions." & vbCrLf
& _
vbCrLf & _
"Regards," & vbCrLf & _
"Chris"


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

"eckert1961" wrote in message
...
Hello,

I am using the following code to construct the strMailBody in Word 2003
VBA
module.

strMailBody = _
vbCrLf & vbCrLf & "Hello " & _
objMerge.DataSource.DataFields("FirstName") & "," & _
vbCrLf & vbCrLf & _
"Please find attached a receipt for your recent payment." & vbCrLf &
vbCrLf & _
"Don't hesitate to contact me should you have any questions." &
vbCrLf
& _
vbCrLf & _
"Regards," & vbCrLf & _
"Chris"

This works but I would like to change this to do the following. I need to
check the .DataFields(ParentsNames) to see if it's null. If it is then
enter
.DataFields(FirstName). If it isn't null then I want to enter
.Datafields(ParentsNames).

What is the required syntax? Thanks in advance.

Regards,
Chris


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
eckert1961 eckert1961 is offline
external usenet poster
 
Posts: 2
Default Email MailMerge strMailBody Question

Thanks for the quick reply Doug. I only had to make one minor change to your
code.

You noted the following line in the Else statement.

objMerge.DataSource.DataFields("FirstName")

I had to change it to the following.

strAddressee = objMerge.DataSource.DataFields("FirstName")

Your recommendation does exactly what I needed. I really appreciate your
assistance.

Take care,
Chris

--
Regards,
Chris


"Doug Robbins - Word MVP" wrote:

Use:

Dim strAddressee as String
If objMerge.DataSource.DataFields("ParentsName") "" then
strAddressee = objMerge.DataSource.DataFields("ParentsName")
Else
objMerge.DataSource.DataFields("FirstName")
End if
strMailBody = _
vbCrLf & vbCrLf & "Hello " & _
strAddressee & "," & _
vbCrLf & vbCrLf & _
"Please find attached a receipt for your recent payment." & vbCrLf &
vbCrLf & _
"Don't hesitate to contact me should you have any questions." & vbCrLf
& _
vbCrLf & _
"Regards," & vbCrLf & _
"Chris"


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

"eckert1961" wrote in message
...
Hello,

I am using the following code to construct the strMailBody in Word 2003
VBA
module.

strMailBody = _
vbCrLf & vbCrLf & "Hello " & _
objMerge.DataSource.DataFields("FirstName") & "," & _
vbCrLf & vbCrLf & _
"Please find attached a receipt for your recent payment." & vbCrLf &
vbCrLf & _
"Don't hesitate to contact me should you have any questions." &
vbCrLf
& _
vbCrLf & _
"Regards," & vbCrLf & _
"Chris"

This works but I would like to change this to do the following. I need to
check the .DataFields(ParentsNames) to see if it's null. If it is then
enter
.DataFields(FirstName). If it isn't null then I want to enter
.Datafields(ParentsNames).

What is the required syntax? Thanks in advance.

Regards,
Chris


.

  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Email MailMerge strMailBody Question

Yes, that was a typo.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

"eckert1961" wrote in message
...
Thanks for the quick reply Doug. I only had to make one minor change to
your
code.

You noted the following line in the Else statement.

objMerge.DataSource.DataFields("FirstName")

I had to change it to the following.

strAddressee = objMerge.DataSource.DataFields("FirstName")

Your recommendation does exactly what I needed. I really appreciate your
assistance.

Take care,
Chris

--
Regards,
Chris


"Doug Robbins - Word MVP" wrote:

Use:

Dim strAddressee as String
If objMerge.DataSource.DataFields("ParentsName") "" then
strAddressee = objMerge.DataSource.DataFields("ParentsName")
Else
objMerge.DataSource.DataFields("FirstName")
End if
strMailBody = _
vbCrLf & vbCrLf & "Hello " & _
strAddressee & "," & _
vbCrLf & vbCrLf & _
"Please find attached a receipt for your recent payment." & vbCrLf
&
vbCrLf & _
"Don't hesitate to contact me should you have any questions." &
vbCrLf
& _
vbCrLf & _
"Regards," & vbCrLf & _
"Chris"


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services
on
a paid professional basis.

"eckert1961" wrote in message
...
Hello,

I am using the following code to construct the strMailBody in Word 2003
VBA
module.

strMailBody = _
vbCrLf & vbCrLf & "Hello " & _
objMerge.DataSource.DataFields("FirstName") & "," & _
vbCrLf & vbCrLf & _
"Please find attached a receipt for your recent payment." & vbCrLf
&
vbCrLf & _
"Don't hesitate to contact me should you have any questions." &
vbCrLf
& _
vbCrLf & _
"Regards," & vbCrLf & _
"Chris"

This works but I would like to change this to do the following. I need
to
check the .DataFields(ParentsNames) to see if it's null. If it is then
enter
.DataFields(FirstName). If it isn't null then I want to enter
.Datafields(ParentsNames).

What is the required syntax? Thanks in advance.

Regards,
Chris


.


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mailmerge question colblip New Users 15 August 8th 09 03:59 PM
Mailmerge question Vicki13 Mailmerge 1 August 2nd 08 11:25 PM
Mailmerge to Email General Question ajatgp Mailmerge 4 April 17th 08 06:49 AM
Mailmerge and VBA Question jim Mailmerge 5 January 25th 07 05:29 PM
Another mailmerge question Colonel Blip New Users 9 September 1st 06 05:48 PM


All times are GMT +1. The time now is 01:27 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"