Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
newschapmj1 newschapmj1 is offline
external usenet poster
 
Posts: 1
Default Invalid merge field

We have a large collection of mail merge templates containing an "Invalid
Merge Field" (ie field is not in the data source)

Option 1 is to add the missing field to the data source.
-i.e. an empty data item

Option 2 is to remove the missing field by VB

I have found scripts that process folders of documents.
eg http://gregmaxey.mvps.org/Process_Batch_Folder.htm

I'm not sure how to remove a mail merge field (eg "InvalidField").
Changing it is not any use to me.
I can modify the data source to prevent the "Invalid Merge Field" dialog
appearing during processing

We are using Word 2002.
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Invalid merge field

Hi newschapmj1,

Is there a reason you can't delete the problem fields from the mailmerge templates?

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"newschapmj1" wrote in message ...
We have a large collection of mail merge templates containing an "Invalid
Merge Field" (ie field is not in the data source)

Option 1 is to add the missing field to the data source.
-i.e. an empty data item

Option 2 is to remove the missing field by VB

I have found scripts that process folders of documents.
eg http://gregmaxey.mvps.org/Process_Batch_Folder.htm

I'm not sure how to remove a mail merge field (eg "InvalidField").
Changing it is not any use to me.
I can modify the data source to prevent the "Invalid Merge Field" dialog
appearing during processing

We are using Word 2002.

  #3   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 Invalid merge field

The following is a modifiation of the code in the article "Find & ReplaceAll
on a batch of documents in the same folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

that should do what you want as long as you get the code of the mergefield
correct.

Dim mf As Field
Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document

PathToUse = "C:\Test\"
'Set the directory and type of file to batch process
myFile = Dir$(PathToUse & "*.doc")
While myFile ""
'Open document
Set myDoc = Documents.Open(PathToUse & myFile)
'Iterate through the fields in the document
For Each mf In myDoc.Fields
If UCase(mf.Code) = "MERGEFIELD NAMEOFMISSINGFIELD" Then
mf.Delete
End If
Next mf
'Close the modified document after saving changes
myDoc.Close SaveChanges:=wdSaveChanges
'Next file in folder
myFile = Dir$()
Wend

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

"newschapmj1" wrote in message
...
We have a large collection of mail merge templates containing an "Invalid
Merge Field" (ie field is not in the data source)

Option 1 is to add the missing field to the data source.
-i.e. an empty data item

Option 2 is to remove the missing field by VB

I have found scripts that process folders of documents.
eg http://gregmaxey.mvps.org/Process_Batch_Folder.htm

I'm not sure how to remove a mail merge field (eg "InvalidField").
Changing it is not any use to me.
I can modify the data source to prevent the "Invalid Merge Field" dialog
appearing during processing

We are using Word 2002.



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
invalid merge fields with word 2003, foxpro 9 Daniel Williams Mailmerge 2 January 17th 08 12:14 AM
datasource field selection change causing invalid data displayed deb Mailmerge 0 January 7th 08 10:14 PM
how to suppress Invalid Merge Field prompt Francisc Molnar Mailmerge 1 April 4th 06 09:44 AM
Invalid Operation with Mail Merge using Split Database Joel' Mailmerge 1 January 27th 06 07:19 PM
suppress invalid merge field word 2003 Mike Mailmerge 3 December 9th 04 11:13 AM


All times are GMT +1. The time now is 10:34 PM.

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"