Creating a new instance of Word
The first step in the process of creating a Word document from within Excel requires some changes to the available references. To be exact, we'll have to set a reference to Word's object library in the VBA Editor. Without this step, Excel cannot communicate with Word at all, let alone create documents and paragraphs.
In this recipe, we will be creating a new instance of Word from within Excel.
Getting ready
Open Excel, and activate a new workbook. Save the file as a macro-enabled file on your desktop and call it Word_Interaction.xlsm
. Sheet1 should be active. Press Alt + F11 to switch to the VBA Editor, and then insert a new module.
It goes without saying that MS Word must also be installed on your computer in order for the instructions in this recipe to work effectively.
How to do it…
Here is how to link Word to Excel:
- In the VBA Editor, click on Tools | References. The References - VBAProject dialog box will...