![]() |
|
#1
|
|||
|
|||
|
Is there a way to test if a activedocument.MailMerge.DataSource.FieldNames("My Field") exists?
Thanks |
|
#2
|
||||
|
||||
|
You could loop through the fieldnames collection and compare with your field name
Code:
Dim iFld As Integer
Dim bFound As Boolean
For iFld = 1 To ActiveDocument.MailMerge.DataSource.FieldNames.Count
'Debug.Print ActiveDocument.MailMerge.DataSource.FieldNames(iFld)
If UCase(ActiveDocument.MailMerge.DataSource.FieldNames(iFld)) = "MY FIELD" Then
MsgBox "'My Field' exists"
bFound = True
Exit For
End If
Next iFld
If Not bFound Then MsgBox "'My Field' does not exist"
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#3
|
|||
|
|||
|
Thanks! Works fine!
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
VBA mailmerge all but last row in datasource
|
vincenzo345 | Word VBA | 9 | 09-01-2017 05:57 AM |
| Verify email passwords every week? | cwksr | Outlook | 1 | 08-16-2014 04:29 AM |
| how to get datasource element | ragesz | Mail Merge | 1 | 09-29-2013 07:12 PM |
| Access MailMerge DataSource in VB | advin | Mail Merge | 1 | 01-04-2010 01:34 AM |
| Changing DataSource | ntfirewall | Mail Merge | 0 | 03-30-2007 06:01 AM |