Hello,
I'm looking to find and replace a list of words in a powerpoint full of queen's English words (Analyze = Analyse, Capitalize = Capitalise, etc) and replace them with their American English counterparts. Here is what I've been using so far:
Sub us_qe()
Dim oSld As Slide
Dim oShp As Shape
Dim otxtTemp As TextRange
Dim otxtR As TextRange
Dim strFindWhat As String
Dim strReplaceWith As String
strFindWhat = "Analyze"
strReplaceWith = "analyse"
For Each oSld In ActivePresentation.Slides
ActiveWindow.View.GotoSlide oSld.SlideIndex
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
If oShp.TextFrame.HasText Then
Set otxtR = oShp.TextFrame.TextRange
Set otxtTemp = oShp.TextFrame.TextRange.Find(strFindWhat, 0, False, True)
Do While Not otxtTemp Is Nothing
otxtTemp.Select
If MsgBox("Replace " & strFindWhat & " with " & strReplaceWith & "?", vbYesNo) = vbYes Then otxtTemp.Text = strReplaceWith
Set otxtTemp = otxtR.Find(strFindWhat, otxtTemp.Start + otxtTemp.Length, False, True)
Loop
End If
End If
Next oShp
Next oSld
End Sub
This works great for one word. Takes me to the word, asks if I want to replace it, and does so. I have a few questions here:
1. I don't think this is the right start to go about replacing a list? Array("word 1", "word 2") isn't working at least. I have a list of 30+ words to look for.
2. I'm hoping to keep the case the same, i.e if it finds "Analyse" change to "Analyze" and "analyse" to "analyze". Not sure if MatchCase:=True works here or not
3. I want the macro to search in shapes and tables as well as text boxes.
I have minimal VBA knowledge but would greatly appreciate anyone who takes the time to help!
Thanks!!!