Inside the Visual Basic Editor.
Open Excel and navigate to the Visual Basic Editor.
In the Visual Basic Editor, click Tools > References, select Microsoft Word XX.X Object Library and click OK.
Screenshots here.
Will not run if the Word Object Library is not selected. See above.
Available within the Function/Subroutine
Dim wordApp As Word.ApplicationDim wordDoc As Word.DocumentAvailable to all Functions/Subroutines in the Module
Option ExplicitDim wordApp As Word.ApplicationDim wordDoc As Word.DocumentAvailable to all Modules in the Excel Workbook
Option ExplicitGlobal wordApp As Word.ApplicationGlobal wordDoc As Word.DocumentVariables defined globally.
Creating a blank document with the normal (blank) document template.
Set wordApp = New Word.ApplicationSet wordDoc = wordApp.Documents.AddCreating a new document based on a specific document template.
Dim templateName As String: templateName = "O:\doc\Report.dotm"Set wordApp = New Word.ApplicationSet wordDoc = wordApp.Documents.Add(templateName)Opening an existing document.
Dim wordDocument As String: wordDocument = "O:\doc\Report.docm"Set wordDoc = wordApp.Documents.Open(wordDocument)Insert text at the end of the document.