Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Format the Existing Table in a Word document

To For­mat the Exist­ing Table in a Microsoft Word Doc­u­ment using Microsoft Excel, you need to fol­low the steps below:

  • Cre­ate the object of Microsoft Word
  • Open the already exist­ing word document
  • Make the MS Word visible
  • Get the Table object
  • Edit  the data in table
  • Save the document

 

Cre­ate the object of Microsoft Word

Set obj­Word = CreateObject(“Word.Application”)

Open the already exist­ing word document

Set obj­Doc = objWord.Documents.Open(“D:\EditTable.docx”)

Make the MS Word Visible

objWord.Visible = True

Get the Table object

Set objTable = objDoc.Tables(2)

Fill the data in table

objTable.Cell(1, 1).Range.Text = “I M NEW HERE

Save the Document

objDoc.Save

 

Com­plete Code:

Function FnFormatExistingTable()

   Dim objWord

   Dim objDoc

   Dim objRange

   Set objWord = CreateObject("Word.Application")

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

   objWord.Visible = True    

   Set objTable = objDoc.Tables(2)    

   For i = 1 To 3

      For j = 1 To 3

 objTable.Cell(i, j).Range.Text = "I M NEW HERE"

       Next

    Next   

End Function
Format the Existing Table in a Word document

For­mat the Exist­ing Table in a Word document

 


 

You may also like...

1 Response

  1. Mark says:

    Out­stand­ing! Your clear, straight­for­ward pre­sen­ta­tion just saved me hours of guess­work. Thank you so much!

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: