Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Rinus Rinus is offline
external usenet poster
 
Posts: 1
Default find and replace in a mergefield

I have a mailmergefield in word. if it contains a special character ( the
'#' in my case) this special character must be replaced by the special
character and some text.

example: mergefield= "piet#jan#klaas"
this must be chenged in "piet puk#jan puk#klaas"

i googled for it but did not find any answer.....
  #2   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 in a mergefield

There are three main possibilities:
a. if the data source lets you define a query or view (e.g. if it is
Access), create a query that does the replacement and use that query as your
data source.
b. with some types of data source you can do (a) by specifying the query in
an OpenDataSource command that you issue using Word VBA.
c. merge to a new document, then use Edit|Find/Replace to replace each "#"
by " puk#" in the new document.
However, since that would affect /every/ "#" and not just the ones in the
mergefield you are interested in, you might need to do more than that.

Peter Jamieson

"Rinus" wrote in message
...
I have a mailmergefield in word. if it contains a special character ( the
'#' in my case) this special character must be replaced by the special
character and some text.

example: mergefield= "piet#jan#klaas"
this must be chenged in "piet puk#jan puk#klaas"

i googled for it but did not find any answer.....



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Rinmus Rinmus is offline
external usenet poster
 
Posts: 3
Default find and replace in a mergefield

"Peter Jamieson" wrote in
:

a no the datasource is a text file
b not possible neither
c it should only be changed in one occurrunce of the mergefield

There are three main possibilities:
a. if the data source lets you define a query or view (e.g. if it is
Access), create a query that does the replacement and use that query
as your data source.
b. with some types of data source you can do (a) by specifying the
query in
an OpenDataSource command that you issue using Word VBA.
c. merge to a new document, then use Edit|Find/Replace to replace
each "#"
by " puk#" in the new document.
However, since that would affect /every/ "#" and not just the ones in
the mergefield you are interested in, you might need to do more than
that.

Peter Jamieson

"Rinus" wrote in message
...
I have a mailmergefield in word. if it contains a special character (
the
'#' in my case) this special character must be replaced by the
special character and some text.

example: mergefield= "piet#jan#klaas"
this must be chenged in "piet puk#jan puk#klaas"

i googled for it but did not find any answer.....




  #4   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 in a mergefield

If you do (c) then you can
1. surround the mergefield by characters that do not appear in your text or
data, e.g.

¬{ MERGEFIELD myfield }¬

2. in the output document, do a find/replace using wildcards, replacing

(¬*)(#)(*¬)

by

\1 puk\2 \3

3. Repeat (2) until no replacements are made, then replace ¬ by nothing.


You can do that in VBA if necessary.

There is another approach, which is to use VBA and Word's mailmerge events
to replace the #s by the text you want then insert the result as you merge
each record. If anything, that is the "correct" way to do this, but it's
somewhat harder than using regular VBA so if you want to do it, say so - and
you have to be using Word 2002 or later.

Peter Jamieson


"Rinmus" wrote in message
...
"Peter Jamieson" wrote in
:

a no the datasource is a text file
b not possible neither
c it should only be changed in one occurrunce of the mergefield

There are three main possibilities:
a. if the data source lets you define a query or view (e.g. if it is
Access), create a query that does the replacement and use that query
as your data source.
b. with some types of data source you can do (a) by specifying the
query in
an OpenDataSource command that you issue using Word VBA.
c. merge to a new document, then use Edit|Find/Replace to replace
each "#"
by " puk#" in the new document.
However, since that would affect /every/ "#" and not just the ones in
the mergefield you are interested in, you might need to do more than
that.

Peter Jamieson

"Rinus" wrote in message
...
I have a mailmergefield in word. if it contains a special character (
the
'#' in my case) this special character must be replaced by the
special character and some text.

example: mergefield= "piet#jan#klaas"
this must be chenged in "piet puk#jan puk#klaas"

i googled for it but did not find any answer.....






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 multiple characters in one find using MSword find/replace Cliff Microsoft Word Help 2 October 29th 06 07:48 PM
How to Find a 'Printing' Paragraph symbol using 'Find & Replace' A.N. Microsoft Word Help 3 July 3rd 06 03:07 AM
Trying to replace words with fields using Find/Replace mbleyle Microsoft Word Help 2 March 29th 06 11:35 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


All times are GMT +1. The time now is 11:25 AM.

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"