Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word multi print

Status
Not open for further replies.

alring

Technical User
Nov 11, 2005
18
DK
Hi

I have a calculation in Excel2003. The result from that calculation is the numbers of copies I need to print of a word2003 document. Is it possible to make a macro in Excel or Word that can do that?? It might be nessesary to oben the Word document first to accept some changes that have been done in it before. So it will be best if it's a macro in Word that can read the resolt in Excel.

Best Regards
Mads
 
Make the number of times to print a variable, and pass it to Word's print command.

Code:
Dim intPrintJobs As Integer
 intPrintJobs = [i]result of calculation[/i]
 [COLOR=red]....make instance of Word
 ....open document[/color red]
    
 Application.PrintOut FileName:="", _
   Range:=wdPrintAllDocument, Item:= _
   wdPrintDocumentContent, Copies:=intPrintJob

Gerry
 
Hi Gerry

I get a message saying in Word that the number have to be between 1 and 32767. If i try to write:
Application.PrintOut FileName:="", _
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=intPrintJob
in excel then the message "Object doesn't support this property or method"
So there is something wrong because I can't get it to work. And also When i write the command above in a macro in Word. then when I open the Word document with Excel then the macro is not there.
Maybe it will be easier if I don't have to open the Word document first.
Hope you still can help me.

Best regards
Mads
 
If the macro is in excel, replace this:
Application.PrintOut
By something like this:
yourWordApplicationObject.PrintOut

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH

Thank you for the help. But it doesn't work. When i run the macro then I get the messag that say "Object required" and "run-time error "424""

Right now the macro look like this:
Dim intPrintJobs As Integer
intPrintJobs = Range("a1")
fNameAndPath = Range("c1")
Application.PrintOut Filename:=fNameAndPath, _
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=intPrintJob
End Sub

"a1" is the numbers of copies I need and "c1" is the document I want to print.

Best regards
Mads
 
And Application is an Excel.Application object ?
If so you can't call its PrintOut method with Word.Application syntax ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi

Cell "c1" is the path and file name of the document I want to print. That file can be a Word file or a PDF file.

I want that Excel can print the document.

If I understand you (PHV) right then can't i make excel to print that document. Is that right??

Mads
 
Hi to the ones that have tried to help me.

I have on another website found what I needed. The macro is like this:

intPrintJobs = Range("a2")
aNameAndPath = Range("a1")
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
appWD.Documents.Open Filename:=aNameAndPath
appWD.ActiveDocument.PrintOut , Copies:=intPrintJobs

"A2" Is the numbers of copies I need
"A1" Is the path and the filename of the document I want to print.

But anyway Thank you for helping me.

Best regards
Mads
 
That file can be a Word file or a PDF file
What happens for PDF files ?
 
This one only works for Word documents not for PDF files. Maybe you can help me with that.

By the way by changing
appWD.Visible = True
to
appWD.Visible = false
then the macro only print the Word document.

mads
 
Hi Mads,

Here's a non-vba solution for printing the document:

If you insert a PRINT field into the document, coded as:
{PRINT \p page /#copies 2 def}
you'll get two copies of whatever page the field is on. Put it in the header or footer, and you'll get two copies of every page.

You can replace the '2' in the field with another field (eg FILLIN, MERGEFIELD, LINK, INCLUDETEXT, etc) to provide the number. Setting the number to 0 prevents the page from printing, though it doesn’t prevent the creation of a printable pdf. In fact, this field has no effect at all on pdf creation.

For the problem you were trying to solve, you could insert the field, coded as per the above, then select the 'copies' cell in your Excel worksheet and use Edit|Paste Special (paste as link) to paste the cell's value into Word as unformatted text. Then, provided you have 'update links' checked, under Tools|Options|Print, the value will refresh at print time.

Cheers
 
Oops - missed some essential quote characters from the field:
{PRINT \p page "/#copies 2 def"}

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top