Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-29-2011, 05:58 PM
blankenthorst blankenthorst is offline Replace all occurrences of one merge field with plain text Windows 7 32bit Replace all occurrences of one merge field with plain text Office 2007
Novice
Replace all occurrences of one merge field with plain text
 
Join Date: Jun 2011
Posts: 4
blankenthorst is on a distinguished road
Default Replace all occurrences of one merge field with plain text

I have a very large Word 2007 mail merge doc with several dozen data fields, one of which is repeated over 300 times throughout the doc (it's a training guide, if you're curious). I'd like to replace that one field - all 300+ times - with plain text, just remove the field entirely and have a typed text string in its place. Can someone give me a push in the right direction? I can't quite figure out what to put in the "Find what" and "Replace with" boxes in the Find/Replace dialog. Is it even possible to "zap" fields in this manner using Find/Replace?



Thanks!
Reply With Quote
  #2  
Old 06-29-2011, 07:30 PM
macropod's Avatar
macropod macropod is offline Replace all occurrences of one merge field with plain text Windows 7 64bit Replace all occurrences of one merge field with plain text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi blankenhorst,

You could use a macro like:
Code:
Sub Demo()
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
  With oFld
    If .Type = wdFieldMergeField Then
      If Trim(Replace(Replace(.Code, "MERGEFIELD", ""), Chr(34), "")) = "MyFieldName" Then .Unlink
    End If
  End With
Next
End Sub
or:
Code:
Sub Demo()
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
  With oFld
    If .Type = wdFieldMergeField Then
      If Trim(Replace(Replace(.Code, "MERGEFIELD", ""), Chr(34), "")) = "MyFieldName" Then
        .Code.Text = "QUOTE " & Chr(34) & "My Text" & Chr(34)
        .Update
        .Unlink
      End If
    End If
  End With
Next
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 06-30-2011, 04:30 AM
blankenthorst blankenthorst is offline Replace all occurrences of one merge field with plain text Windows 7 32bit Replace all occurrences of one merge field with plain text Office 2007
Novice
Replace all occurrences of one merge field with plain text
 
Join Date: Jun 2011
Posts: 4
blankenthorst is on a distinguished road
Default Thank you, Paul

So it appears that this is a feature that does not natively exist in Word, which seems odd. After all, there is a way to replace all occurrences of a static text string with a field. Is there no way to do the reverse except writing a custom macro?
Reply With Quote
  #4  
Old 06-30-2011, 04:43 AM
blankenthorst blankenthorst is offline Replace all occurrences of one merge field with plain text Windows 7 32bit Replace all occurrences of one merge field with plain text Office 2007
Novice
Replace all occurrences of one merge field with plain text
 
Join Date: Jun 2011
Posts: 4
blankenthorst is on a distinguished road
Default Thanks again, Paul

Wrote the macro and ran it. Works like a magic wand. Thanks!
Reply With Quote
  #5  
Old 06-30-2011, 06:01 PM
macropod's Avatar
macropod macropod is offline Replace all occurrences of one merge field with plain text Windows 7 64bit Replace all occurrences of one merge field with plain text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi blankenhorst,

With Find/Replace, with field codes displayed (eg by pressing Alt-F9), using ^d as the Find expression will find any field. That might do if the mergefields you want to replace are the only fields in the document, but not otherwise.

PS: You shouldn't need to re-type the macro - copy/paste should do.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 07-01-2011, 05:18 AM
blankenthorst blankenthorst is offline Replace all occurrences of one merge field with plain text Windows 7 32bit Replace all occurrences of one merge field with plain text Office 2007
Novice
Replace all occurrences of one merge field with plain text
 
Join Date: Jun 2011
Posts: 4
blankenthorst is on a distinguished road
Default

Thank you, macropod. I didn't know about the ^d thing. But yeah, since I have several dozen merge fields, and I only want to flatten all of the occurrences of one field, I'll have to stick with the macro for now. However, I appreciate the reply.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace all occurrences of one merge field with plain text Html send as plain text JosSchaars Outlook 5 12-21-2010 02:51 PM
Replace all occurrences of one merge field with plain text Selecting merge field based on whether or not text is present amym Mail Merge 1 12-07-2010 05:14 AM
Replace All with plain text containing subscript DeaducK Word 0 06-24-2010 08:16 PM
merge field formatting problem with "text to be inserted before" wissam Mail Merge 0 12-13-2009 12:50 AM
Text field after word merge in Word 2000 brianlb Word 1 06-29-2009 07:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:39 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft