+ Reply to Thread
Results 1 to 5 of 5

Printing a Word Doc

  1. #1
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162

    Printing a Word Doc

    Hi!
    What type of code would I use to print a Word document by clicking a button or drawn object in an Excel worksheet? I do not want to see the document just open the Word application print the document ("Instructions") and close the Word application. The Word document is in the same file folder as the Excel workbook that is accessing it.

    Thanks for any and all help!!

  2. #2
    Chip Pearson
    Guest

    Re: Printing a Word Doc

    Try

    Dim WordApp As Object
    Dim WordDoc As Object
    Set WordApp = CreateObject("Word.Application")
    WordApp.Visible = False
    Set WordDoc = WordApp.documents.Open(ThisWorkbook.Path &
    "\Instructions.doc")
    WordDoc.PrintOut
    WordDoc.Close savechanges:=False
    WordApp.Quit


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "Brian Matlack"
    <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Hi!
    > What type of code would I use to print a Word document by
    > clicking a
    > button or drawn object in an Excel worksheet? I do not want to
    > see the
    > document just open the Word application print the document
    > ("Instructions") and close the Word application. The Word
    > document is
    > in the same file folder as the Excel workbook that is accessing
    > it.
    >
    > Thanks for any and all help!!
    >
    >
    > --
    > Brian Matlack
    > ------------------------------------------------------------------------
    > Brian Matlack's Profile:
    > http://www.excelforum.com/member.php...fo&userid=3508
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=548754
    >




  3. #3
    AA2e72E
    Guest

    Re: Printing a Word Doc

    The WordDoc object is unnecessary.
    WordApp.Viaible is False by default.
    Need to Set WordApp = Nothing

    Modified Solution:

    Set WordApp = CreateObject("Word.Application")
    WordApp.Open ThisWorkbook.Path & "\Instructions.doc"
    WordApp.ActiveDocument.PrintOut
    WordApp.ActiveDocument.Close SaveChanges:=False
    WordApp.Quit
    Set WordApp = Nothing

    The line

    WordApp.ActiveDocument.Close SaveChanges :=False

    is necessary because the document may have links that get updated thereby
    marking the document as changed.

    "Chip Pearson" wrote:

    > Try
    >
    > Dim WordApp As Object
    > Dim WordDoc As Object
    > Set WordApp = CreateObject("Word.Application")
    > WordApp.Visible = False
    > Set WordDoc = WordApp.documents.Open(ThisWorkbook.Path &
    > "\Instructions.doc")
    > WordDoc.PrintOut
    > WordDoc.Close savechanges:=False
    > WordApp.Quit
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    >
    > "Brian Matlack"
    > <[email protected]>
    > wrote in message
    > news:[email protected]...
    > >
    > > Hi!
    > > What type of code would I use to print a Word document by
    > > clicking a
    > > button or drawn object in an Excel worksheet? I do not want to
    > > see the
    > > document just open the Word application print the document
    > > ("Instructions") and close the Word application. The Word
    > > document is
    > > in the same file folder as the Excel workbook that is accessing
    > > it.
    > >
    > > Thanks for any and all help!!
    > >
    > >
    > > --
    > > Brian Matlack
    > > ------------------------------------------------------------------------
    > > Brian Matlack's Profile:
    > > http://www.excelforum.com/member.php...fo&userid=3508
    > > View this thread:
    > > http://www.excelforum.com/showthread...hreadid=548754
    > >

    >
    >
    >


  4. #4
    Chip Pearson
    Guest

    Re: Printing a Word Doc

    WordApp.Open ThisWorkbook.Path & "\Instructions.doc"

    This line won't work. You need

    WordApp.Documents.Open ThisWorkbook.Path & "\Instructions.doc"

    > WordApp.Viaible is False by default.


    Not true. In Office 2003, you'll see the application window with
    the instructions.doc file open on the screen if you don't set
    Visible to False.

    > Need to Set WordApp = Nothing


    False. As long as WordApp is a local variable, it is
    automatically destroyed when the procedure ends.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "AA2e72E" <[email protected]> wrote in message
    news:[email protected]...
    > The WordDoc object is unnecessary.
    > WordApp.Viaible is False by default.
    > Need to Set WordApp = Nothing
    >
    > Modified Solution:
    >
    > Set WordApp = CreateObject("Word.Application")
    > WordApp.Open ThisWorkbook.Path & "\Instructions.doc"
    > WordApp.ActiveDocument.PrintOut
    > WordApp.ActiveDocument.Close SaveChanges:=False
    > WordApp.Quit
    > Set WordApp = Nothing
    >
    > The line
    >
    > WordApp.ActiveDocument.Close SaveChanges :=False
    >
    > is necessary because the document may have links that get
    > updated thereby
    > marking the document as changed.
    >
    > "Chip Pearson" wrote:
    >
    >> Try
    >>
    >> Dim WordApp As Object
    >> Dim WordDoc As Object
    >> Set WordApp = CreateObject("Word.Application")
    >> WordApp.Visible = False
    >> Set WordDoc = WordApp.documents.Open(ThisWorkbook.Path &
    >> "\Instructions.doc")
    >> WordDoc.PrintOut
    >> WordDoc.Close savechanges:=False
    >> WordApp.Quit
    >>
    >>
    >> --
    >> Cordially,
    >> Chip Pearson
    >> Microsoft MVP - Excel
    >> Pearson Software Consulting, LLC
    >> www.cpearson.com
    >>
    >>
    >>
    >> "Brian Matlack"
    >> <[email protected]>
    >> wrote in message
    >> news:[email protected]...
    >> >
    >> > Hi!
    >> > What type of code would I use to print a Word document by
    >> > clicking a
    >> > button or drawn object in an Excel worksheet? I do not want
    >> > to
    >> > see the
    >> > document just open the Word application print the document
    >> > ("Instructions") and close the Word application. The Word
    >> > document is
    >> > in the same file folder as the Excel workbook that is
    >> > accessing
    >> > it.
    >> >
    >> > Thanks for any and all help!!
    >> >
    >> >
    >> > --
    >> > Brian Matlack
    >> > ------------------------------------------------------------------------
    >> > Brian Matlack's Profile:
    >> > http://www.excelforum.com/member.php...fo&userid=3508
    >> > View this thread:
    >> > http://www.excelforum.com/showthread...hreadid=548754
    >> >

    >>
    >>
    >>




  5. #5
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162
    The Code Worked Great Chip! Thanks!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1