Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Using Excel Macro to Print Word Documents

I am trying to set up a macro to print an Excel document. This was easy
enough but the Excel document has links to word documents that display the
visuals that accompany the Excel text. The macro will need to Print the word
documents with the Excel spread sheet. My current macro stops as soon as
word is opened as if there is no communication link between Excel and Word.
I basically just need the macro (in Excel) to open, print, and close a word
document. Any ideas? Help!
--
Michael J. Nowak
Energy Systems/Dow Chemical
Texas City, TX
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Using Excel Macro to Print Word Documents

Mike,

With your VBE window open, click 'Tools References' and put a check by
"Microsoft Word 11.0 Object library" (note, it may not be 11.0 if you have a
different version of Office than me) The example below opens Word if it
wasn't already open, opens and prints the document "C:\Scripts\Test1.doc",
closes the document and if Word wasn't open in advance it closes the Word
application. You may want to change the line that makes the Word
application visible so you don't see the window flash but this version will
give you a sense of the timing.

_____________________________________

Sub PrintWordDoc()
Dim bStarted As Boolean
Dim oApp As Word.Application

On Error Resume Next
Set oApp = GetObject(, "Word.Application")
'Get the running instance of Word, if there is no instance
'create a new one:
If Err < 0 Then
bStarted = True
Set oApp = CreateObject("Word.Application")
End If

oApp.Activate
oApp.Visible = True

oApp.Documents.Open ("C:\Scripts\Test1.doc")

oApp.PrintOut

oApp.ActiveDocument.Close wdDoNotSaveChanges

'Quit only when Word was not running when we started this code
If bStarted Then
oApp.Quit
End If


Set oApp = Nothing
End Sub

_______________________________________

Steve


"Mike" .(donotspam) wrote in message
...
I am trying to set up a macro to print an Excel document. This was easy
enough but the Excel document has links to word documents that display the
visuals that accompany the Excel text. The macro will need to Print the
word
documents with the Excel spread sheet. My current macro stops as soon as
word is opened as if there is no communication link between Excel and
Word.
I basically just need the macro (in Excel) to open, print, and close a
word
document. Any ideas? Help!
--
Michael J. Nowak
Energy Systems/Dow Chemical
Texas City, TX



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Using Excel Macro to Print Word Documents

Thanks a bunch, Steve. That worked. I really appreciate your help. Hope
you had a good weekend,
--
Michael J. Nowak
Energy Systems/Dow Chemical
Texas City, TX


"Steve Yandl" wrote:

Mike,

With your VBE window open, click 'Tools References' and put a check by
"Microsoft Word 11.0 Object library" (note, it may not be 11.0 if you have a
different version of Office than me) The example below opens Word if it
wasn't already open, opens and prints the document "C:\Scripts\Test1.doc",
closes the document and if Word wasn't open in advance it closes the Word
application. You may want to change the line that makes the Word
application visible so you don't see the window flash but this version will
give you a sense of the timing.

_____________________________________

Sub PrintWordDoc()
Dim bStarted As Boolean
Dim oApp As Word.Application

On Error Resume Next
Set oApp = GetObject(, "Word.Application")
'Get the running instance of Word, if there is no instance
'create a new one:
If Err < 0 Then
bStarted = True
Set oApp = CreateObject("Word.Application")
End If

oApp.Activate
oApp.Visible = True

oApp.Documents.Open ("C:\Scripts\Test1.doc")

oApp.PrintOut

oApp.ActiveDocument.Close wdDoNotSaveChanges

'Quit only when Word was not running when we started this code
If bStarted Then
oApp.Quit
End If


Set oApp = Nothing
End Sub

_______________________________________

Steve


"Mike" .(donotspam) wrote in message
...
I am trying to set up a macro to print an Excel document. This was easy
enough but the Excel document has links to word documents that display the
visuals that accompany the Excel text. The macro will need to Print the
word
documents with the Excel spread sheet. My current macro stops as soon as
word is opened as if there is no communication link between Excel and
Word.
I basically just need the macro (in Excel) to open, print, and close a
word
document. Any ideas? Help!
--
Michael J. Nowak
Energy Systems/Dow Chemical
Texas City, TX




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
Too many word documents, can Excel HELP!!! Jerry Excel Discussion (Misc queries) 1 May 13th 08 08:07 PM
Print errors with Word documents in Excel spreadsheets mike-ss Excel Discussion (Misc queries) 0 August 10th 05 05:11 PM
Ever use Excel for documents instead of Word? [email protected] Excel Discussion (Misc queries) 2 March 18th 05 10:55 AM
I cannot print out Excel documents. I can print emails. Sandi Excel Discussion (Misc queries) 1 March 1st 05 01:11 PM
Creating Word Documents with an Excel Macro The Wonder Thing[_2_] Excel Programming 1 June 19th 04 12:15 AM


All times are GMT +1. The time now is 05:15 PM.

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

About Us

"It's about Microsoft Excel"