Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find+Replace Dialog Box, Replace with Format problem | Microsoft Word Help | |||
Find multiple characters in one find using MSword find/replace | Microsoft Word Help | |||
Using find and replace or macros to replace page ranges | Microsoft Word Help | |||
Find/ Replace is auto-capping the words I want to replace with | Microsoft Word Help | |||
Replace mergefields with form fields | Mailmerge |