Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Format already written text in a word document – Format All Content

VBA-Excel: Format already written text in a word document – Format All Content

To Format already written text in a word document – Format All Content Microsoft Word Document using Microsoft Excel, you need to follow the steps below:

  • Create the object of Microsoft Word
  • Create Doc object 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.
  • Select the Whole content in the word document
  • Do the formatting
  • Save the word document
  • Close the word document


Create the object of Microsoft Word

Set objWord = CreateObject(“Word.Application”)

Create Doc object 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

Select the Whole content in the word document

objSelection.WholeStory

Do the formatting

objSelection.Font.Name = "Algerian"

objSelection.Font.Bold = True

objSelection.Font.Color = RGB(12, 200, 0)

Save the Word Document

objDoc.Save

Close the word document

objWord.Quit

Complete Code:

Function FnFormatAllContent()

   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.WholeStory

   objSelection.Font.Name = "Algerian"

   objSelection.Font.Bold = True

   objSelection.Font.Color = RGB(12, 200, 0)

   objDoc.Save

   objWord.Quit

End Function
FormatAllContent
FormatAllContent



Also Read:

  1. VBA-Excel: Convert Numbers (Rupees) into Words OR Text - Updated Till 1000000 Crore With Decimal Numbers
  2. VBA-Excel: Edit And Save an Existing Word Document
  3. VBA-Excel: Login To Already Opened GMAIL In An Internet Explorer (IE)
  4. VBA-Excel - Merger - Merge or Combine Many Word Documents Into One
  5. Send Mail With Multiple Different Attachments From MS Outlook using Excel.
  6. VBA-Excel: Add/Insert a Image/Picture in Word Document
  7. VBA-Excel: Create worksheets with Names in Specific Format/Pattern.
  8. VBA-Excel: Get ALL The Opened Internet Explorer (IE) using Microsoft Excel