C
Cheryl
Hi,
I am pretty new to VB and MailMerge. I am doing a mailmerge with a
csv data source and it has a variable number of fields named by their
doc name with a "Y" value if they are to be included.
I was wondering if I can use INCLUDETEXT from within VBA. (It seems
that I have to use VB to get the names of the fields (and count
variable number of fields) Basically, what I want is a variable
number of IF-THEN-ELSE fields that use INCLUDETEXT. (with variable
field names)
{IF {MERGEFIELD <fieldname>}="Y" "{INCLUDETEXT "C:\\<fieldname>.doc"}"
""}
Is there a way to
1. Loop through fields from within word
2. Get the field names?
Or, in VBA can I use INCLUDETEXT within the TrueText of an AddIf
statement?
I have:
For Each afield In wrdDoc.MailMerge.DataSource.FieldNames
wrdMergeFields.AddIf Range:=wrdSelection.Range, _
MergeField:=afield.Name, Comparison:=wdMergeIfEqual,
CompareTo:="Y", _
TrueText:=afield.Name + vbCrLf
Next afield
which works great for listing the names of the files!
What I need is something like:
TrueText:="{INCLUDETEXT" & quote & "C:\\" & afield.name & ".doc"} &
quote
Is there a way to do this?
Thanks very much in advance for any help you can provide.
Cheryl Kinden
I am pretty new to VB and MailMerge. I am doing a mailmerge with a
csv data source and it has a variable number of fields named by their
doc name with a "Y" value if they are to be included.
I was wondering if I can use INCLUDETEXT from within VBA. (It seems
that I have to use VB to get the names of the fields (and count
variable number of fields) Basically, what I want is a variable
number of IF-THEN-ELSE fields that use INCLUDETEXT. (with variable
field names)
{IF {MERGEFIELD <fieldname>}="Y" "{INCLUDETEXT "C:\\<fieldname>.doc"}"
""}
Is there a way to
1. Loop through fields from within word
2. Get the field names?
Or, in VBA can I use INCLUDETEXT within the TrueText of an AddIf
statement?
I have:
For Each afield In wrdDoc.MailMerge.DataSource.FieldNames
wrdMergeFields.AddIf Range:=wrdSelection.Range, _
MergeField:=afield.Name, Comparison:=wdMergeIfEqual,
CompareTo:="Y", _
TrueText:=afield.Name + vbCrLf
Next afield
which works great for listing the names of the files!
What I need is something like:
TrueText:="{INCLUDETEXT" & quote & "C:\\" & afield.name & ".doc"} &
quote
Is there a way to do this?
Thanks very much in advance for any help you can provide.
Cheryl Kinden