FozzieBeara
New Member
- Joined
- May 12, 2011
- Messages
- 3
Hello:
I have cobbled together a Word Macro that I wish to use to print multiple Word email attachments that I have downloaded and opened in multiple active windows (I say "cobbled" because I really don't know how to write VBA code other than by cutting and pasting from things I've found on the web. )
The macro works perfectly until after the last document has been printed and closed wherein I get the following error: "Run-time error '4605': This method or property is not available because a document window is not active." And then what ends up getting highlighted by the Word debugger is the second "Application.PrintOut" command lines...which confuses me. (I bolded the part where the debugger says there is an error.)
So, I was wondering if anyone would be able to offer some assistance with this...(also, if there's a way to turn off the "This document has track changes. Do you still want to print" etc. and other track-changes related prompts). Also, if you can recommend any specific books/websites that would provide more of an over-view and comprehensive understanding of VBA as it relates to Word that would also be very helpful.
Thanks in advance!
I have cobbled together a Word Macro that I wish to use to print multiple Word email attachments that I have downloaded and opened in multiple active windows (I say "cobbled" because I really don't know how to write VBA code other than by cutting and pasting from things I've found on the web. )
The macro works perfectly until after the last document has been printed and closed wherein I get the following error: "Run-time error '4605': This method or property is not available because a document window is not active." And then what ends up getting highlighted by the Word debugger is the second "Application.PrintOut" command lines...which confuses me. (I bolded the part where the debugger says there is an error.)
So, I was wondering if anyone would be able to offer some assistance with this...(also, if there's a way to turn off the "This document has track changes. Do you still want to print" etc. and other track-changes related prompts). Also, if you can recommend any specific books/websites that would provide more of an over-view and comprehensive understanding of VBA as it relates to Word that would also be very helpful.
Thanks in advance!
Sub PrintMultipleEmailAttachments()
Application.PrintOut fileName:="", Range:=wdPrintAllDocument, Item:=wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=False
ActiveDocument.Close SaveChanges:=False
Do While intCounter < 500 (**I just choose an arbitrary number of 500 so that it wouldn't stop in the middle if I had an excessive number of downloaded documents to print)
intCounter = intCounter + 1
Application.PrintOut fileName:="", Range:=wdPrintAllDocument, Item:=wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=False
ActiveDocument.Close SaveChanges:=False
Loop
End Sub