Is there a
way to write VBA code to open a word document print it
and close it?
This is routing OLE automation code: just remember that what follows has
not been checked: you'll need to look up the functions in Word VBA help
files:
' get a new Word instance
' it's harder to find an existing running instance, but it
' doesn't matter so don't bother
'
' On the other hand, if you set a reference to Word library
' in VBEditor, you can just use Dim as New instead
Set appWord = GetObject(, "Word.Application")
' This line is optional, but it makes the user feel better if
' the application actually appears on screen. GetObject always
' leaves the object invisible
appWord.Visible = True
' Open the document: you can use this method to set passwords,
' readonly status and so on
Set doc = appWord.Documents.Open("c:\docs\mydoc.doc")
' I haven't used this method much: you can choose which pages
' to print and so on
doc.PrintOut
' Tidying up
doc.Close
appWord.Quit
' All done
Hope that helps
Tim F