I am tring to create a macro (in Excel) to open another excel worksheet, do a find-replace, then save it.
I have already achieved this with a word document like this:
...
Dim wrdDoc As Word.Document
If wrdApp Is Nothing Then Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open(TemplateFilePath)
...
Call WordReplace(wrdDoc,"a","b")
....
Private Sub WordReplace(wrdDoc As Word.Document, sFind As String, sReplace As String)
With wrdDoc.Content.Find
.Text = sFind
.Replacement.Text = sReplace
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
End Sub
I have crudely tried to replace the word “Word” with “Excel” in the above code to no avail.
Can somone point me in the right direction please?
You could do: