Microsoft Word is a word processing application that is part of the Office suite. VBA is commonly used to automate routine tasks in Office applications such as Word. If you're working with Excel you may need to transfer text from a spreadsheet to Microsoft Word. In a few simple steps you can create a function to add text to a Word document using VBA.
Open Microsoft Office 2007, click "Developer" tab and select "Visual Basic". Click "Tools", select "References" and check "Microsoft Word 12.0 Object Library. Select "OK".
Type the following to create a function:
Private Function insertTextToWord()
Type the following to create your variables:
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Type the following to open Word and add a new document:
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
Type the following to add text to your document:
Execute your function.