- Joined
- Jul 21, 2021
- Messages
- 3
- Reaction score
- 0
Hello ALL,
Need your help. And I know in advance that the built-in "CTRL + H" function is supposed to give an appropriate answer - but in my case it is not. Because of text language issues, and because I have a lot of characters that are not "letters or numbers" - the usual search and swap causes mistakes.
And now for the request - and many many thanks in advance!
I was able to "scrape" and revamp a relatively simple code, which performs a search and replacement of the entire document, to which I was able to thread MSGBOX for requests confirmation for each replacement:
* "OK" button - confirms a single replacement.
* "No" button - skips this search - and does not make a switch.
* "Cancel" button - stops the macro.
1. How do you add a fourth button that will perform "Replace All"?
2. Is there a "count-down" option for running without user intervention? I want the default to be "Ok", and even if I did not press, then after 3 seconds - a change will be made.
3. I've been breaking my head for many days - and can not convert this code that will only work in selected / marked text.
=-=-=-=-=-=- HERE IS THE CODE I USE -=-=-=-=-=-=
Sub Want2Replace()
Dim myRange As Range
Set myRange = ActiveDocument.Content
myRange.Find.ClearFormatting
myRange.Find.MatchWildcards = True
Dim cached As Long
cached = myRange.End
Do While myRange.Find.Execute("åÀ")
myRange.Select
MyAnswer = MsgBox("Replace " & myRange.Find.Text & "?", vbYesNoCancel)
If MyAnswer = vbYes Then Call Shva_Na
If MyAnswer = vbCancel Then Exit Sub
myRange.Start = myRange.Start + Len(myRange.Find.Text)
myRange.End = cached
Loop
End Sub
Need your help. And I know in advance that the built-in "CTRL + H" function is supposed to give an appropriate answer - but in my case it is not. Because of text language issues, and because I have a lot of characters that are not "letters or numbers" - the usual search and swap causes mistakes.
And now for the request - and many many thanks in advance!
I was able to "scrape" and revamp a relatively simple code, which performs a search and replacement of the entire document, to which I was able to thread MSGBOX for requests confirmation for each replacement:
* "OK" button - confirms a single replacement.
* "No" button - skips this search - and does not make a switch.
* "Cancel" button - stops the macro.
1. How do you add a fourth button that will perform "Replace All"?
2. Is there a "count-down" option for running without user intervention? I want the default to be "Ok", and even if I did not press, then after 3 seconds - a change will be made.
3. I've been breaking my head for many days - and can not convert this code that will only work in selected / marked text.
=-=-=-=-=-=- HERE IS THE CODE I USE -=-=-=-=-=-=
Sub Want2Replace()
Dim myRange As Range
Set myRange = ActiveDocument.Content
myRange.Find.ClearFormatting
myRange.Find.MatchWildcards = True
Dim cached As Long
cached = myRange.End
Do While myRange.Find.Execute("åÀ")
myRange.Select
MyAnswer = MsgBox("Replace " & myRange.Find.Text & "?", vbYesNoCancel)
If MyAnswer = vbYes Then Call Shva_Na
If MyAnswer = vbCancel Then Exit Sub
myRange.Start = myRange.Start + Len(myRange.Find.Text)
myRange.End = cached
Loop
End Sub