Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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!!


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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"

wrote in message
news:Brian.Matlack.28y7wm_1149543606.4021@excelfor um-nospam.com...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default 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"

wrote in message
news:Brian.Matlack.28y7wm_1149543606.4021@excelfor um-nospam.com...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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" wrote in message
...
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"

wrote in message
news:Brian.Matlack.28y7wm_1149543606.4021@excelfor um-nospam.com...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Printing a Word Doc


The Code Worked Great Chip! Thanks!!


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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing a Word doc with a macro Alec H Excel Discussion (Misc queries) 0 February 23rd 06 10:46 AM
Embedding Word Docs into Excel Worksheets and Then Printing The Word Docs mr_melvis Excel Worksheet Functions 1 April 8th 05 03:00 AM
Excel VBA printing to MS Word cause MS Word to crash, why? alruff Excel Programming 0 October 4th 04 09:57 PM
Printing Word Document using Excel Programming hangs Word Alan Excel Programming 0 September 30th 04 08:41 PM
Printing a Word doc from Excel Danny[_4_] Excel Programming 18 October 27th 03 03:13 PM


All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"