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

VBA-Excel: Open and Print the Word Document

To open an exist­ing Microsoft Word Doc­u­ment  and print it using Microsoft Excel, you need to fol­low the steps below:

  • Cre­ate the object of Microsoft Word
  • Cre­ate Doc object using MS word object, Open the exist­ing word doc­u­ment by pro­vid­ing the com­plete path
  • Make the MS Word visible
  • Print the word document
  • Close the word document

 

Cre­ate the object of Microsoft Word

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

Cre­ate Doc object using MS word object, Open the exist­ing word doc­u­ment by pro­vid­ing the com­plete path

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

Make the MS Word Visible

objWord.Visible = True

Print the word document

obj­Doc.Print­Out

Close the word document

obj­Word.Quit

 

 

Com­plete Code:

Function FnPrint()

  Dim objWord

  Dim objDoc

  Set objWord = CreateObject("Word.Application")

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

  objWord.Visible = True

  objDoc.PrintOut

  objWord.Quit

End Function

 

You may also like...

Leave a Reply

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

%d bloggers like this: