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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word open trigger

Status
Not open for further replies.

faxof

Programmer
Joined
Dec 5, 2001
Messages
272
Location
GB
how do i get my code to print when word opens

i.e.
when someone opens my document
print the document
close the document
end


i tried:
Code:
Private Sub App_DocumentOpen(ByVal Doc As Document)
    ActiveDocument.PrintOut
    ActiveDocument.Close
End Sub
am i using the wrong code or am i putting it in the wrong place?

quizzed
faxof
 
***i use this to print the document
Application.PrintOut FileName:="", Range:=wdPrintCurrentPage, Item:= _
wdPrintDocumentContent, Copies:=2, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=False, PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
*** i use this to close the document
Application.Quit Savechanges:=wdDoNotSaveChanges

try putting this in the autoexecute macro of the doc you want to open print and close automatically. If you do this and then cannot open the file to edit it you will have to add the /m to the word command line to get back into your file.
 
where's the autoexecute macro?
 
Hi,

Create a Module (Insert + Module), and write a macro called AutoOpen() in the VBA editor. Digga

Sharing Knowledge Saves Valuable Time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top