![]() |
|
|
|
#1
|
|||
|
|||
|
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
|
| Tags |
| acvitedocument, selection |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to save active document to SharePoint document library | Rose roon | Word VBA | 9 | 09-22-2015 10:53 PM |
copy active document to shared network drive
|
Rose roon | Word VBA | 9 | 07-04-2015 09:55 PM |
Copying text from another to Active document
|
AlexTeslin | Word VBA | 1 | 03-08-2013 09:06 PM |
| Drag Button which refers to the active Word document to Explorer | DRob | Word | 0 | 10-03-2010 06:40 AM |
| Document selection procedure | kennethc | Word | 0 | 09-15-2010 02:56 PM |