Print problem

D

Dudley

I am trying to print with code:

Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
ActivePrinter = "HP LaserJet 4050 PS"
objWord.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="2-20", PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True, Background:= _
True, PrintToFile:=True, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0,
OutputFileName:=PrnDocName, _
Append:=False
ActiveDocument.Close (wdDoNotSaveChanges)

I get the command 'objWord.Printout...Append:=False' highlighted with error
message 4605, 'method or property not available because document window not
active' (even though I have already opened the document as a form letter).

Can anyone help?
Thanks
Dudley
 
J

Jezebel

First, if this code is in a Word macro, you don't need to fetch a reference
to the Word application. You've got that already with the 'Application'
keyword. Which you don't need anyway, because the current application is
assumed, eg as you already have for the ActivePrinter command. (You could
use Application.ActivePrinter and Application.ActiveDocument, but there's no
need.)

Second, the error refers to the entire PrintOut statement, not just the
Append line. Word is complaining that it doesn't know what you want to
print. ActiveDocument, presumably (not the word application). So all you
need is ---

PrnDocName = "..."

ActivePrinter = "HP LaserJet 4050 PS"
ActiveDocument.Printout Range:=wdPrintRangeOfPages, Pages:="2-20",
OutputFileName:=PrnDocName
ActiveDocument.Close SaveChanges:=FALSE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top