Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Printing a Word doc with a macro | Excel Discussion (Misc queries) | |||
Embedding Word Docs into Excel Worksheets and Then Printing The Word Docs | Excel Worksheet Functions | |||
Excel VBA printing to MS Word cause MS Word to crash, why? | Excel Programming | |||
Printing Word Document using Excel Programming hangs Word | Excel Programming | |||
Printing a Word doc from Excel | Excel Programming |