Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
viensdansmavie viensdansmavie is offline
external usenet poster
 
Posts: 8
Default find and replace with logic

anybody know the answer this question?
Words €śbook€ť and €śpen€ť word has changed location, change the location on
these two by using a function in the program (Microsoft Word) without losing
any of the words. What is important is to understand how to do this.
Hint:
You can use logic and function. (Function: replace all)
t.ex
Take a box a apple and a melon.

put apple and melon on the table.

If you replace the apple with a new melon.

And then replace the melons with apples.

So You've no melons left. This is what happens when you run the function
replace all.

Now you can with the help of box do anything crafty so we have both apple
and melon still make the switch locations. But thus need to do things in more
than two steps. (three steps)

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default find and replace with logic

Hopefully you will understand if I don't completely understand your
question. I am often accused of not reading for content. If I understand
you correctly you want to swap words around in pairs. Change all "book" to
"pen" change all "pen" to "book" change all "melons" to "apples" changes all
"apples" to "melons."

There could be other ways, but one way is to use a pair of temporary unique
text strings and a macro as follows:

Sub ScratchMacro()
Dim pFWIP As String
Dim pSWIP As String
Dim oRng As Word.Range
pFWIP = InputBox("Enter first word of pair.")
pSWIP = InputBox("Enter second word of pair.")
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = pFWIP
.Replacement.Text = "$$$$"
.Execute Replace:=wdReplaceAll
.Text = pSWIP
.Replacement.Text = "@@@@"
.Execute Replace:=wdReplaceAll
.Text = "$$$$"
.Replacement.Text = pSWIP
.Execute Replace:=wdReplaceAll
.Text = "@@@@"
.Replacement.Text = pFWIP
.Execute Replace:=wdReplaceAll
End With
End Sub


viensdansmavie wrote:
anybody know the answer this question?
Words "book" and "pen" word has changed location, change the location
on these two by using a function in the program (Microsoft Word)
without losing any of the words. What is important is to understand
how to do this.
Hint:
You can use logic and function. (Function: replace all)
t.ex
Take a box a apple and a melon.

put apple and melon on the table.

If you replace the apple with a new melon.

And then replace the melons with apples.

So You've no melons left. This is what happens when you run the
function replace all.

Now you can with the help of box do anything crafty so we have both
apple and melon still make the switch locations. But thus need to do
things in more than two steps. (three steps)


--
Greg Maxey

See my web site http://gregmaxey.mvps.org
for an eclectic collection of Word Tips.

"It is not the critic who counts, not the man who points out how the
strong man stumbles, or where the doer of deeds could have done them
better. The credit belongs to the man in the arena, whose face is
marred by dust and sweat and blood, who strives valiantly...who knows
the great enthusiasms, the great devotions, who spends himself in a
worthy cause, who at the best knows in the end the triumph of high
achievement, and who at the worst, if he fails, at least fails while
daring greatly, so that his place shall never be with those cold and
timid souls who have never known neither victory nor defeat." - TR



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default find and replace with logic

Another way is with a three-step Replace process (which is what your
teacher seems to have in mind). Replace "book" with "pencil." Replace
"pen" with "book." Replace "pencil" with "pen."

Unfortunately it looks like you've gotten both Greg and me to do your
homework for you.

On Sep 20, 9:39*pm, viensdansmavie
wrote:
anybody know the answer this question?
Words “book” and “pen” word has changed location, change the location on
these two by using a function in the program (Microsoft Word) without losing
any of the words. What is important is to understand how to do this.
Hint:
You can use logic and function. (Function: replace all)
t.ex
Take a box a apple and a melon.

put apple and melon on the table.

If you replace the apple with a new melon.

And then replace the melons with apples.

So You've no melons left. This is what happens when you run the function
replace all.

Now you can with the help of box do anything crafty so we have both apple
and melon still make the switch locations. But thus need to do things in more
than two steps. (three steps)


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
viensdansmavie viensdansmavie is offline
external usenet poster
 
Posts: 8
Default find and replace with logic

))
Change location=book and pen but Book and pen will always appear in text. I
understand question thus and we must use €śreplace all€ť function
Auxiliary word: pencil
I tried your answer I wrote 3 words first
book
pencil
pen
and I €śreplaced all€ť book with pencil now there is pencil, pencil and pen.
Book became invisible in text. Auxiliary word can invisible only.
I try this for 3 days. What strange question or I understand wrong everything


"Peter T. Daniels" wrote:

Another way is with a three-step Replace process (which is what your
teacher seems to have in mind). Replace "book" with "pencil." Replace
"pen" with "book." Replace "pencil" with "pen."

Unfortunately it looks like you've gotten both Greg and me to do your
homework for you.

On Sep 20, 9:39 pm, viensdansmavie
wrote:
anybody know the answer this question?
Words €śbook€ť and €śpen€ť word has changed location, change the location on
these two by using a function in the program (Microsoft Word) without losing
any of the words. What is important is to understand how to do this.
Hint:
You can use logic and function. (Function: replace all)
t.ex
Take a box a apple and a melon.

put apple and melon on the table.

If you replace the apple with a new melon.

And then replace the melons with apples.

So You've no melons left. This is what happens when you run the function
replace all.

Now you can with the help of box do anything crafty so we have both apple
and melon still make the switch locations. But thus need to do things in more
than two steps. (three steps)



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default find and replace with logic

Mr. Daniels is correct. The process does not require the fourth step.
However, I do recommend a unique temporary string (e.g. "licnep" instead of
"pencil") something that is unlikely to appear elsewhere in the text. If
you want to use a macro approach the code is revised as follows:

Sub ScratchMacro()
Dim pFWIP As String
Dim pSWIP As String
Dim oRng As Word.Range
pFWIP = InputBox("Enter first word of pair.")
pSWIP = InputBox("Enter second word of pair.")
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = pFWIP
.Replacement.Text = "$$$$"
.Execute Replace:=wdReplaceAll
.Text = pSWIP
.Replacement.Text = pFWIP
.Execute Replace:=wdReplaceAll
.Text = "$$$$"
.Replacement.Text = pSWIP
.Execute Replace:=wdReplaceAll
End With
End Sub

You should keep in mind that this process can give some
unintended/unexpected results. Using "pen" and "book" as the word pair, in
basic form:

I have a book and a pen.

would be changed to:

I have a pen and a book.

Now if you have:

I have a pen and some books. You can have a book.

The result will depend on your MatchWholeWord setting. If set to "false"
true the result will be:

I have a book and some pens. You can have a pen.

If set to "true" the result will be:

I have a book and some books. You can have a pen.

You might say. I'll be sure to use "false" as my MatchWholeWord setting.
You should then consider:

I have some books, some pencils and a pen. You can have a book.

The result:

I have some pens, some bookcils and a book. You can have a pen.

My point is that it can get complicated so be sure to consider carefully
what you do and check the result.


viensdansmavie wrote:
anybody know the answer this question?
Words "book" and "pen" word has changed location, change the location
on these two by using a function in the program (Microsoft Word)
without losing any of the words. What is important is to understand
how to do this.
Hint:
You can use logic and function. (Function: replace all)
t.ex
Take a box a apple and a melon.

put apple and melon on the table.

If you replace the apple with a new melon.

And then replace the melons with apples.

So You've no melons left. This is what happens when you run the
function replace all.

Now you can with the help of box do anything crafty so we have both
apple and melon still make the switch locations. But thus need to do
things in more than two steps. (three steps)


--
Greg Maxey

See my web site http://gregmaxey.mvps.org
for an eclectic collection of Word Tips.

"It is not the critic who counts, not the man who points out how the
strong man stumbles, or where the doer of deeds could have done them
better. The credit belongs to the man in the arena, whose face is
marred by dust and sweat and blood, who strives valiantly...who knows
the great enthusiasms, the great devotions, who spends himself in a
worthy cause, who at the best knows in the end the triumph of high
achievement, and who at the worst, if he fails, at least fails while
daring greatly, so that his place shall never be with those cold and
timid souls who have never known neither victory nor defeat." - TR





  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default find and replace with logic


I believe Mr. Daniels intended for you to start with two paired words:

Jane has a book and a pen. Sally has a book and a pen.

Using ReplaceAll replace book with pencil. Then first intermediate result
is:

Jane has a pencil and a pen. Sally has a pencil and a pen.

Using ReplaceAll replace pen with book. The sencond intermediate result is:

Jane has a pencil and a book. Sally has a pencil and a book.

Using ReplaceAll replace pencil with pen. The final result is:

Jane has a pen and a book. Sally has a pen and a book.

The words pen and book have been interchanged.

viensdansmavie wrote:
))
Change location=book and pen but Book and pen will always appear in
text. I understand question thus and we must use "replace all"
function
Auxiliary word: pencil
I tried your answer I wrote 3 words first
book
pencil
pen
and I "replaced all" book with pencil now there is pencil, pencil
and pen. Book became invisible in text. Auxiliary word can invisible
only.
I try this for 3 days. What strange question or I understand wrong
everything


"Peter T. Daniels" wrote:

Another way is with a three-step Replace process (which is what your
teacher seems to have in mind). Replace "book" with "pencil." Replace
"pen" with "book." Replace "pencil" with "pen."

Unfortunately it looks like you've gotten both Greg and me to do your
homework for you.

On Sep 20, 9:39 pm, viensdansmavie
wrote:
anybody know the answer this question?
Words "book" and "pen" word has changed location, change the
location on these two by using a function in the program (Microsoft
Word) without losing any of the words. What is important is to
understand how to do this.
Hint:
You can use logic and function. (Function: replace all)
t.ex
Take a box a apple and a melon.

put apple and melon on the table.

If you replace the apple with a new melon.

And then replace the melons with apples.

So You've no melons left. This is what happens when you run the
function replace all.

Now you can with the help of box do anything crafty so we have both
apple and melon still make the switch locations. But thus need to
do things in more than two steps. (three steps)


--
Greg Maxey

See my web site http://gregmaxey.mvps.org
for an eclectic collection of Word Tips.

"It is not the critic who counts, not the man who points out how the
strong man stumbles, or where the doer of deeds could have done them
better. The credit belongs to the man in the arena, whose face is
marred by dust and sweat and blood, who strives valiantly...who knows
the great enthusiasms, the great devotions, who spends himself in a
worthy cause, who at the best knows in the end the triumph of high
achievement, and who at the worst, if he fails, at least fails while
daring greatly, so that his place shall never be with those cold and
timid souls who have never known neither victory nor defeat." - TR



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default find and replace with logic

Precisely. The problem you set was to interchange two words, and the
only way to do this is to go through a third word (which does not
appear in the final product). Mr. Maxey did it with a macro, and I did
it in a way that shows you how the macro works.

If you have to exchange three words, you need to use four words in the
process, and so on.

(It's like the "Towers of Hanoi" puzzle, where you need to move a
stack of different size discs from one post to another -- you need a
third post for them to "rest" on while you are carrying out the
moves.)

On Sep 21, 6:51*am, "Greg Maxey"
wrote:
I believe Mr. Daniels intended for you to start with two paired words:

Jane has a book and a pen. *Sally has a book and a pen.

Using ReplaceAll replace book with pencil. *Then first intermediate result
is:

Jane has a pencil and a pen. *Sally has a pencil and a pen.

Using ReplaceAll replace pen with book. *The sencond intermediate result is:

Jane has a pencil and a book. *Sally has a pencil and a book.

Using ReplaceAll replace pencil with pen. *The final result is:

Jane has a pen and a book. *Sally has a pen and a book.

The words pen and book have been interchanged.





viensdansmavie wrote:
))
Change location=book and pen but Book and pen will always appear in
text. I understand question thus and we must use "replace all"
function
Auxiliary word: pencil
I tried your answer I wrote 3 words first
book
pencil
pen
and *I "replaced all" book with pencil now there is pencil, pencil
and pen. Book became invisible in text. Auxiliary word can invisible
only.
I try this for 3 days. What strange question or I understand wrong
everything


"Peter T. Daniels" wrote:


Another way is with a three-step Replace process (which is what your
teacher seems to have in mind). Replace "book" with "pencil." Replace
"pen" with "book." Replace "pencil" with "pen."


Unfortunately it looks like you've gotten both Greg and me to do your
homework for you.


On Sep 20, 9:39 pm, viensdansmavie
wrote:
anybody know the answer this question?
Words "book" and "pen" word has changed location, change the
location on these two by using a function in the program (Microsoft
Word) without losing any of the words. What is important is to
understand how to do this.
Hint:
You can use logic and function. (Function: replace all)
t.ex
Take a box a apple and a melon.


put apple and melon on the table.


If you replace the apple with a new melon.


And then replace the melons with apples.


So You've no melons left. This is what happens when you run the
function replace all.


Now you can with the help of box do anything crafty so we have both
apple and melon still make the switch locations. But thus need to
do things in more than two steps. (three steps)


--
Greg Maxey

See my web sitehttp://gregmaxey.mvps.org
for an eclectic collection of Word Tips.

"It is not the critic who counts, not the man who points out how the
strong man stumbles, or where the doer of deeds could have done them
better. The credit belongs to the man in the arena, whose face is
marred by dust and sweat and blood, who strives valiantly...who knows
the great enthusiasms, the great devotions, who spends himself in a
worthy cause, who at the best knows in the end the triumph of high
achievement, and who at the worst, if he fails, at least fails while
daring greatly, so that his place shall never be with those cold and
timid souls who have never known neither victory nor defeat." - *TR-

  #8   Report Post  
Posted to microsoft.public.word.docmanagement
viensdansmavie viensdansmavie is offline
external usenet poster
 
Posts: 8
Default find and replace with logic

thanks guys
good job
i take good degree from my teacher
/mvh



"Greg Maxey" wrote:

Mr. Daniels is correct. The process does not require the fourth step.
However, I do recommend a unique temporary string (e.g. "licnep" instead of
"pencil") something that is unlikely to appear elsewhere in the text. If
you want to use a macro approach the code is revised as follows:

Sub ScratchMacro()
Dim pFWIP As String
Dim pSWIP As String
Dim oRng As Word.Range
pFWIP = InputBox("Enter first word of pair.")
pSWIP = InputBox("Enter second word of pair.")
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = pFWIP
.Replacement.Text = "$$$$"
.Execute Replace:=wdReplaceAll
.Text = pSWIP
.Replacement.Text = pFWIP
.Execute Replace:=wdReplaceAll
.Text = "$$$$"
.Replacement.Text = pSWIP
.Execute Replace:=wdReplaceAll
End With
End Sub

You should keep in mind that this process can give some
unintended/unexpected results. Using "pen" and "book" as the word pair, in
basic form:

I have a book and a pen.

would be changed to:

I have a pen and a book.

Now if you have:

I have a pen and some books. You can have a book.

The result will depend on your MatchWholeWord setting. If set to "false"
true the result will be:

I have a book and some pens. You can have a pen.

If set to "true" the result will be:

I have a book and some books. You can have a pen.

You might say. I'll be sure to use "false" as my MatchWholeWord setting.
You should then consider:

I have some books, some pencils and a pen. You can have a book.

The result:

I have some pens, some bookcils and a book. You can have a pen.

My point is that it can get complicated so be sure to consider carefully
what you do and check the result.


viensdansmavie wrote:
anybody know the answer this question?
Words "book" and "pen" word has changed location, change the location
on these two by using a function in the program (Microsoft Word)
without losing any of the words. What is important is to understand
how to do this.
Hint:
You can use logic and function. (Function: replace all)
t.ex
Take a box a apple and a melon.

put apple and melon on the table.

If you replace the apple with a new melon.

And then replace the melons with apples.

So You've no melons left. This is what happens when you run the
function replace all.

Now you can with the help of box do anything crafty so we have both
apple and melon still make the switch locations. But thus need to do
things in more than two steps. (three steps)


--
Greg Maxey

See my web site http://gregmaxey.mvps.org
for an eclectic collection of Word Tips.

"It is not the critic who counts, not the man who points out how the
strong man stumbles, or where the doer of deeds could have done them
better. The credit belongs to the man in the arena, whose face is
marred by dust and sweat and blood, who strives valiantly...who knows
the great enthusiasms, the great devotions, who spends himself in a
worthy cause, who at the best knows in the end the triumph of high
achievement, and who at the worst, if he fails, at least fails while
daring greatly, so that his place shall never be with those cold and
timid souls who have never known neither victory nor defeat." - TR




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
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 08:03 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"