WORD VBA Search and switch to advanced ...

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
 
Joined
Jul 21, 2021
Messages
3
Reaction score
0
After many hours and many attempts, I understand that: Question 1 will be solved only with the help of "text box" Question 2 - It has no solution Question 3 - I still need your help. PLEASE.

Here is the question:

How can I search and replace in a selected section of a document, with the MSGBOX as in the example?

you are welcome!!!

Thanx alot!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top