Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Writing Text to Word document

For writing text in Microsoft Word Document using Microsoft Excel, you need to follow the steps below:

  • Create the object of Microsoft Word
  • Add documents to the Word
  • Make the MS Word visible
  • Create a Selection object with the help of WordObject.
  • Use this Selection object to type the text into the WordDocument.

Create the object of Microsoft Word

Set objWord = CreateObject(“Word.Application”)

Add documents to the Word

Set objDoc = objWord.Documents.Add

Make the MS Word Visible

objWord.Visible = True

Create a Selection object with the help of WordObject.

Set objSelection = objWord.Selection

Use this Selection object to type the text into the WordDocument.

objSelection.TypeText ("This is my text in Word Document using Excel")

Complete Code:

FunctionFnWriteToWordDoc()
   Dim objWord
   Dim objDoc

   Dim objSelection

   Set objWord = CreateObject("Word.Application")

   Set objDoc = objWord.Documents.Add    

   objWord.Visible = True

   Set objSelection = objWord.Selection

   objSelection.TypeText ("This is my text in Word Document using Excel")

End Function
Word- Write using Excel
Word- Write using Excel



Also Read:

  1. Excel-VBA : Insert Multiple Images from a Folder to Excel Cells
  2. VBA-Excel: Working with Bookmarks- Insert text before Bookmark
  3. Excel-VBA : Send Mail with Embedded Image in message body From MS Outlook using Excel.
  4. VBA-Excel: Format already written text in a word document – Format All Content
  5. Introduction to Excel WorkBook
  6. VBA-Excel: Get ALL The Opened Internet Explorer (IE) using Microsoft Excel
  7. Excel-VBA : Open a MS Word Document using Excel File using Explorer Window.
  8. VBA-Excel: Appending Text to an Existing Word Document - at the End