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" <mjnowak@dow.com.(donotspam)> wrote in message
news:5AE7C19C-7208-4A0F-A9A8-783107B52C11@microsoft.com...
>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
Bookmarks