Skip to content

Instantly share code, notes, and snippets.

@JoeGlines
Created April 22, 2021 20:33
Show Gist options
  • Save JoeGlines/0249ef852ae51bf8ce0b1d1a142ad461 to your computer and use it in GitHub Desktop.
Save JoeGlines/0249ef852ae51bf8ce0b1d1a142ad461 to your computer and use it in GitHub Desktop.
;*******************************************************
; Want a clear path for learning AutoHotkey; Take a look at our AutoHotkey Udemy courses. They're structured in a way to make learning AHK EASY
; Right now you can get a coupon code here: https://the-Automator.com/Learn
;*******************************************************
#SingleInstance,Force
SetBatchLines,-1
;**************************************
Wd:=ComObjCreate("Word.Application") ;this would activate an open one
WD.Visible:=0 ;This is fun to watch, but it will be much, much faster if you set this to zero and have it running w/o being visible
;********************Get list of files***********************************
FileSelectFile,Files,m,%A_ScriptDir%,,Text Documents (*.docx; *.doc)
;*********Use For loop over Var going line by line*********************
MsgBox % Files
for i, File in Loopobj:=StrSplit(Files,"`n","`r`n") { ;Parse Var on each new line
If (I=1){
Path:=File "\"
Continue
}
Menu , tray, tip, % round((i-1)/(Loopobj.maxindex()-1)*100) "% done. " i-1 " of " Loopobj.maxindex()-1
WD.Documents.Open(Path File, 0, 1, 0)
WD.Selection.WholeStory ;Select all text
WD.Selection.font.Name:="Calibri" ;Change the selected text to the font you want
newFile:=Path File "_Calibri.docx" ;Add _Calibri to the name (note this will overwrite other files)
WD.ActiveDocument.SaveAs(newFile)
WD.ActiveDocument.Close()
}
WD.Quit() ;Make sure you quit Word when it is done
MsgBox Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment