Hi,
I want to be able to run a macro on a Word 2010 document that i currently have open.
The code below shows the working macro with an open call, what I want to do is run the macro on any opened document, without having to manually set the file.
Any suggestions?
Thank you.
Code:
Sub FontReplaceTimesNewRoman()
'
' FontReplaceTimesNewRoman Macro
'
'
Dim objWordApp As Word.Application
Dim objWordDoc As Word.Document
Dim objSelection As Selection
Dim FileString As String
Const wdReplaceAll = 2
Set objWordApp = CreateObject("Word.Application")
FileString = "C:\Downloads\VerificationProcedures.docx"
objWordApp.Documents.Open (FileString)
objWordApp.Visible = True
Set objWordDoc = objWordApp.ActiveDocument
Set objSelection = objWordApp.Selection
objSelection.Find.Font.Name = "Times New Roman"
objSelection.Find.Forward = True
objSelection.Find.Replacement.Font.Name = "Calibri"
objSelection.Find.Execute "", , False, , , , , , , , wdReplaceAll
objWordApp.Documents.Close (Word.WdSaveOptions.wdSaveChanges)
objWordApp.Quit
Set objWordApp = Nothing
End Sub