Good morning!
I have a script I wrote about a year ago that was cumbersome to begin with but is becoming more and more unwieldly as time goes on!
I'm not very good at VBA, but I can work with rudimentary syntax if it's easy enough for me to see and figure out what is going on and what I have to do.
The simple code I found via recording keystrokes puts the structure below into my macro. I now have somewhere between 40 and 50 of these search and replace code blocks (!!!):
Code:
'----------------------------------------------
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Orbis factor"
.Replacement.Text = "Órbis fáctor"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
'----------------------------------------------
I don't even know if it's possible to simplify this in the way I'm going to describe, but I have to ask to see. It would be ideal, I think, to just have something simple where instead of each time having to add a code block for a new search and replace, that I can add just 2 lines with the target and desired code (?).
i.e., in the example above, the document I get that I need to edit is missing emphasis accents in the Latin, such as this:
Orbis factor
For clarity's sake, I need to edit to show syllable emphasis, like this:
Órbis fáctor
If at all possible, it would be easier to maintain a word list (preferably contained within the macro itself and not accessing the information from an external source -- not sure if this is procedure but in an automation language I do now how to use quite a bit better than VBA, this is a common procedure).
This type of solution with a word/phrase list would mean that I can then keep everything orderly and easy to maintain as I'd put all these words/phrases to be edited in alphabetical order (with first word/phrase being how it gets sent to me, followed by accented or diphthong corrections I need to make) ... :
ae
æ
Dicit
Dícit
Est
Ést
Nunc
Núnc
Orbis factor
Órbis fáctor
(etc., etc.)
This may not be even possible, I just don't know. All I know is that I need a structure that is as easy to work with as the simple, 1-item-per-row list above (?).
I hope that I've explained okay. If more clarification is needed, please let me know.
Thank you!