Finding matches from a list and replacing from another list, one by one (not global)
I need to create a pair of macros, one to replace specified characters in font A with the corresponding characters in font B, and one to do the same thing the other way around.
-----------
MACRO #1 (FindSymbolReplaceNormal)
This macro should find a specified character in the Symbol font and replace it with the corresponding character in the normal font.
For example, the following code will find all occurrences of the degree symbol in the Symbol font and replace them with the degree symbol in the normal font.
Code:
Sub FindSymbolReplaceNormal()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(61616)
.Replacement.Text = "°"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
EndSub
-----------
MACRO #2 (FindNormalReplaceSymbol)
This macro should find a specified character in the normal font and replace it with the corresponding character in the Symbol font.
For example, the following code will find all occurrences of the degree symbol in the normal font and replace them with the degree symbol in the Symbol font.
Code:
Sub FindNormalReplaceSymbol()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "°"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=-3920, Unicode:=True
End Sub
-----------
Note that finding a character in the Symbol font and replacing it with the corresponding character in the normal font can be done with a direct find/replace function (as in Macro #1), but finding a character in the normal font and replacing it with the corresponding character in the Symbol font cannot be done with a direct find/replace function but needs to be done by first finding the character in the normal font and then using the InsertSymbol function to overwrite it (not simply replace it) with the required character (as in Macro #2).
I would like to make both macros work as follows.
- Each macro should run through a whole document (or a selected block of text) to find and replace all matches, but it should stop on each match and give the user the option of replacing or skipping each one individually, not globally.
- Each macro should specify a list of characters to find, and a corresponding list of characters to replace. The macro should loop through the "find" list and replace matches with the corresponding character from the "replace" list. For example, Macro 1 should find the degree symbol and the plus-or-minus symbol in the Symbol font -- i.e., ChrW(61616) and ChrW(61617) -- and replace them with the corresponding characters in the normal font -- i.e., "°" and "±" respectively; and Macro 2 should do the reverse, but using the InsertSymbol function to overwrite rather than simply replace.
Is this possible?