Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Larry Kahm Larry Kahm is offline
external usenet poster
 
Posts: 3
Default Find and replace mergefields

I've been asked to help change the contents of a main document. The
developer didn't think anyone would need help when he originally designed
the fields, so he gave them non-informative names, e.g., 1, 2, 3, instead of
Name, Street, Organization. Now, some inexperienced staff need help when
they work with the documents.

Is there any way to use Find & Replace to identify and correct the field
names in the mergefields?

Thanks!

Larry


  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Find and replace mergefields

If you display the field codes in the merge document ALT+F9 you can use
Replace to change the field names from 1 to Name, 2 to Street ,or whatever
matches the new field names in your data source. Then CTRL+A F9 to update
them. You will of course first have to make the changes to the field names
in the data source..

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Larry Kahm wrote:
I've been asked to help change the contents of a main document. The
developer didn't think anyone would need help when he originally
designed the fields, so he gave them non-informative names, e.g., 1,
2, 3, instead of Name, Street, Organization. Now, some inexperienced
staff need help when they work with the documents.

Is there any way to use Find & Replace to identify and correct the
field names in the mergefields?

Thanks!

Larry



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Larry Kahm Larry Kahm is offline
external usenet poster
 
Posts: 3
Default Find and replace mergefields

Ah!

But then I have to replace each one manually, right? Because the number 1
may appear "in context," but not in a mergefield field. Is there any way to
distinguish this, say by using VBA?

There are 20 documents, each with at least a dozen sections, so I was hoping
to automate most of the process.

Thanks for your help!

Larry

"Graham Mayor" wrote in message
...
If you display the field codes in the merge document ALT+F9 you can use
Replace to change the field names from 1 to Name, 2 to Street ,or whatever
matches the new field names in your data source. Then CTRL+A F9 to update
them. You will of course first have to make the changes to the field names
in the data source..

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Larry Kahm wrote:
I've been asked to help change the contents of a main document. The
developer didn't think anyone would need help when he originally
designed the fields, so he gave them non-informative names, e.g., 1,
2, 3, instead of Name, Street, Organization. Now, some inexperienced
staff need help when they work with the documents.

Is there any way to use Find & Replace to identify and correct the
field names in the mergefields?

Thanks!

Larry





  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Find and replace mergefields

If you can toggle the field codes ALT+F9 and tell me exactly what they
contain and what they should each be changed to, it should be simple enough
to create a macro to do it ... tomorrow

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Larry Kahm wrote:
Ah!

But then I have to replace each one manually, right? Because the
number 1 may appear "in context," but not in a mergefield field. Is
there any way to distinguish this, say by using VBA?

There are 20 documents, each with at least a dozen sections, so I was
hoping to automate most of the process.

Thanks for your help!

Larry

"Graham Mayor" wrote in message
...
If you display the field codes in the merge document ALT+F9 you can
use Replace to change the field names from 1 to Name, 2 to Street
,or whatever matches the new field names in your data source. Then
CTRL+A F9 to update them. You will of course first have to make the
changes to the field names in the data source..

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Larry Kahm wrote:
I've been asked to help change the contents of a main document. The
developer didn't think anyone would need help when he originally
designed the fields, so he gave them non-informative names, e.g., 1,
2, 3, instead of Name, Street, Organization. Now, some
inexperienced staff need help when they work with the documents.

Is there any way to use Find & Replace to identify and correct the
field names in the mergefields?

Thanks!

Larry



  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Find and replace mergefields

In theory, if your merge field was called "2", you might need to display
all field codes, then find/replace

MERGEFIELD "2"
and possibly
MERGEFIELD 2

In theory you might need to replace some operands in other field types, e.g.

{ =fieldname*2 }

but if your field names are really just numbers than I don't think you
would have any of those.

Field types such as { ADDRESSBLOCK } and { GREETINGLINE } also use data
from the data source, but do not use the field names directly - instead,
they use standardised names that are "mapped" to the real field names.
If you have any of those and you are changing the names in the data
source, then you will probably need to remap the names.


Peter Jamieson

http://tips.pjmsn.me.uk

Larry Kahm wrote:
Ah!

But then I have to replace each one manually, right? Because the number 1
may appear "in context," but not in a mergefield field. Is there any way to
distinguish this, say by using VBA?

There are 20 documents, each with at least a dozen sections, so I was hoping
to automate most of the process.

Thanks for your help!

Larry

"Graham Mayor" wrote in message
...
If you display the field codes in the merge document ALT+F9 you can use
Replace to change the field names from 1 to Name, 2 to Street ,or whatever
matches the new field names in your data source. Then CTRL+A F9 to update
them. You will of course first have to make the changes to the field names
in the data source..

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Larry Kahm wrote:
I've been asked to help change the contents of a main document. The
developer didn't think anyone would need help when he originally
designed the fields, so he gave them non-informative names, e.g., 1,
2, 3, instead of Name, Street, Organization. Now, some inexperienced
staff need help when they work with the documents.

Is there any way to use Find & Replace to identify and correct the
field names in the mergefields?

Thanks!

Larry






  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Find and replace mergefields

The following should do the trick - change the names and numbers as
required.

Sub ReplaceFieldNames()
Dim i As Long
Dim iNum As Long
Dim fName As String
Dim oDoc As Document
Set oDoc = ActiveDocument
With oDoc
For i = 1 To .Fields.Count
If .Fields(i).Type = wdFieldMergeField Then
For iNum = 1 To 3 'Number of fieldnames as numbers to replace
Select Case iNum
Case Is = 1
fName = "Name"
Case Is = 2
fName = "Address1"
Case Is = 3
fName = "City"
Case Else
End Select
.Fields(i).Code.Text = Replace(.Fields(i).Code.Text, iNum,
fName)
Next iNum
End If
Next i
End With
End Sub

--

Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Graham Mayor wrote:
If you can toggle the field codes ALT+F9 and tell me exactly what they
contain and what they should each be changed to, it should be simple
enough to create a macro to do it ... tomorrow


Larry Kahm wrote:
Ah!

But then I have to replace each one manually, right? Because the
number 1 may appear "in context," but not in a mergefield field. Is
there any way to distinguish this, say by using VBA?

There are 20 documents, each with at least a dozen sections, so I was
hoping to automate most of the process.

Thanks for your help!

Larry

"Graham Mayor" wrote in message
...
If you display the field codes in the merge document ALT+F9 you can
use Replace to change the field names from 1 to Name, 2 to Street
,or whatever matches the new field names in your data source. Then
CTRL+A F9 to update them. You will of course first have to make the
changes to the field names in the data source..

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Larry Kahm wrote:
I've been asked to help change the contents of a main document. The
developer didn't think anyone would need help when he originally
designed the fields, so he gave them non-informative names, e.g.,
1, 2, 3, instead of Name, Street, Organization. Now, some
inexperienced staff need help when they work with the documents.

Is there any way to use Find & Replace to identify and correct the
field names in the mergefields?

Thanks!

Larry



  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Larry Kahm Larry Kahm is offline
external usenet poster
 
Posts: 3
Default Find and replace mergefields

Kudos for an outstandingly simple bit of wonderful code!

Larry

"Graham Mayor" wrote in message
...
The following should do the trick - change the names and numbers as
required.

Sub ReplaceFieldNames()
Dim i As Long
Dim iNum As Long
Dim fName As String
Dim oDoc As Document
Set oDoc = ActiveDocument
With oDoc
For i = 1 To .Fields.Count
If .Fields(i).Type = wdFieldMergeField Then
For iNum = 1 To 3 'Number of fieldnames as numbers to replace
Select Case iNum
Case Is = 1
fName = "Name"
Case Is = 2
fName = "Address1"
Case Is = 3
fName = "City"
Case Else
End Select
.Fields(i).Code.Text = Replace(.Fields(i).Code.Text, iNum,
fName)
Next iNum
End If
Next i
End With
End Sub

--

Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Graham Mayor wrote:
If you can toggle the field codes ALT+F9 and tell me exactly what they
contain and what they should each be changed to, it should be simple
enough to create a macro to do it ... tomorrow


Larry Kahm wrote:
Ah!

But then I have to replace each one manually, right? Because the
number 1 may appear "in context," but not in a mergefield field. Is
there any way to distinguish this, say by using VBA?

There are 20 documents, each with at least a dozen sections, so I was
hoping to automate most of the process.

Thanks for your help!

Larry

"Graham Mayor" wrote in message
...
If you display the field codes in the merge document ALT+F9 you can
use Replace to change the field names from 1 to Name, 2 to Street
,or whatever matches the new field names in your data source. Then
CTRL+A F9 to update them. You will of course first have to make the
changes to the field names in the data source..

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Larry Kahm wrote:
I've been asked to help change the contents of a main document. The
developer didn't think anyone would need help when he originally
designed the fields, so he gave them non-informative names, e.g.,
1, 2, 3, instead of Name, Street, Organization. Now, some
inexperienced staff need help when they work with the documents.

Is there any way to use Find & Replace to identify and correct the
field names in the mergefields?

Thanks!

Larry





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
Find+Replace Dialog Box, Replace with Format problem Kathy Microsoft Word Help 3 February 1st 08 04:26 AM
Find multiple characters in one find using MSword find/replace Cliff Microsoft Word Help 2 October 29th 06 07:48 PM
Using find and replace or macros to replace page ranges JeremyC Microsoft Word Help 7 February 13th 06 09:20 PM
Find/ Replace is auto-capping the words I want to replace with Graham Mayor Microsoft Word Help 8 January 27th 06 01:39 AM
Replace mergefields with form fields jassi_Hayre Mailmerge 1 August 16th 05 10:49 PM


All times are GMT +1. The time now is 09:21 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"