Copying data into Word
We could have opened Word manually and achieved what we've just done, but the whole purpose of the exercise is to do it from Excel, so that data in a spreadsheet can be written to the Word document automatically.
What we need to do now is select data, copy it, and then paste that as part of the opening and formatting process.
In this recipe, we will be copying data into Word.
Getting ready
Make sure that Word_Interaction.xlsm
is still open. Activate Sheet1, and enter the following data:
How to do it…
Follow these steps to copy text from Excel to Word:
- Create code to automatically select whatever range is on a sheet:
Sub CreateWordDoc() Dim wdApp As Word.Application Set wdApp = New Word.Application With wdApp .Visible = True &...