What is wrong with the following VBA module: an attempt to standardise font and layout on over 2000 docx MSWord365 pages to Montserrat SemiBold, 14 pt in justified paragraphs?
Text
Sub ConvertMultipleDocumentsFont()
Dim folderPath As String
Dim fileName As String
Dim wdApp As Object, wdDoc As Object
Dim para As Object
folderPath = "D:\VIDEOS\TEST" ' Change to your folder
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = False
fileName = Dir(folderPath & "*.docx")
Do While fileName <> ""
Set wdDoc = wdApp.Documents.Open(folderPath & fileName)
For Each para In wdDoc.Paragraphs
para.Range.ParagraphFormat.Alignment = wdAlignParagraphJustify
para.Range.Font.Name = "Montserrat SemiBold"
para.Range.Font.Size = 14
Next para
wdDoc.Save
wdDoc.Close
fileName = Dir
Loop
wdApp.Quit
Set wdApp = Nothing
End Sub
I have read the Microsoft Ignite Invalid Outside Procedure and Lesson 4 of VBA Tutor.
folderPathends with \ (backslash). Are you running this in Word? If Yes then there's no need to use late binding and you should (eg)Dim wdApp As Word.Application