Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
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 | |||
Trying to replace words with fields using 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 |