Microsoft Office Tutorials and References
In Depth Information
Lesson 27: Working with Word from Excel
Working with Word from excel
With the ubiquitous presence of Microsoft Office, a common task is to create and maintain
documents in Microsoft Word that either accompany, or include as part of their narrative
content, data and information from Excel workbooks. From your own experience, you have
probably seen situations that call for information from Word documents to be appended, printed,
or exported from Word into your Excel workbook.
Word and Excel work very well together in sharing data across their respective applications.
These tasks can be automated with VBA macros right from Excel, to provide your workbook
projects with robust and user-friendly methods of integrating data with Word.
AcTiVATing A Word docuMEnT
In Lesson 26, you saw a macro named LateBindingTest that opens a Word document named
myWordDoc.docx . However, with the everyday world being what it is, a seemingly simple task
like activating a Word document involves a few considerations:
Word might not be open.
Word is open but the document itself is not open.
The Word document is already open.
The Word document you want to open does not exist.
For such tasks that have multiple considerations, the “divide and conquer” approach is a good
way to cover your bases. If you take each consideration in turn, you can craft a single macro
to handle the entire process seamlessly.