Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Edit And Save an Existing Word Document

VBA-Excel: Save an Existing Word Document

To Edit and save an existing Microsoft Word Document using Microsoft Excel, you need to follow the steps below:

  • Create the object of Microsoft Word
  • Using MS word object, Open the existing word document by providing the complete path
  • Make the MS Word visible
  • Create a Selection object with the help of WordObject.
  • Edit the Word Document using SelectionObject
  • Save the Word Document


Create the object of Microsoft Word

Set objWord = CreateObject(“Word.Application”)

Using MS word object, Open the existing word document by providing the complete path

Set objDoc = objWord.Documents.Open("D:\OpenMe.docx")

Make the MS Word Visible

objWord.Visible = True

Create a Selection object with the help of WordObject.

Set objSelection = objWord.Selection

Edit the Word Document using SelectionObject

objSelection.Font.Size = "22"

objSelection.TypeText ("I am new here" & vbCrLf)

Save the Word Document

objDoc.Save

Complete Code:

Function FnEditAndSaveWordDoc()

   Dim objWord

   Dim objDoc

   Dim objSelection

   Set objWord = CreateObject("Word.Application")

   Set objDoc = objWord.Documents.Open("D:\OpenMe.docx")

   objWord.Visible = True

   Set objSelection = objWord.Selection

   objSelection.Font.Bold = True

   objSelection.Font.Size = "22"

   objSelection.TypeText ("I am new here" & vbCrLf)

   objDoc.Save

End Function
Word - Save



Also Read:

  1. VBA-Excel: Format already written text in a word document – Format Paragraphs
  2. VBA-Excel: Open an Existing Word Document
  3. VBA-Excel: Get the Instance of already opened word document
  4. VBA-Excel: Appending Text to an Existing Word Document - at the End
  5. Excel-VBA : Send Unique Images Embedded to Mail Body, With Every Mail From MS Outlook using Excel.