Open - Event

J

Jürgen Magg

Hello!

Ich want that, when I open the document, a message box should appear, with
two buttons: Yes and No and the text: "Would you like to print this
document?"
So I wrote the following code, but it doesn't work:

Private Sub Document_Open()
Dim intResponse As Integer
Dim strName As String
Dim docLoop As Document
intResponse = MsgBox("Would you like to print this document?", vbYesNo)

If intResponse = vbYes Then
' Print
ActiveDocument.PrintOut
End If
End Sub


What's wrong

Jürgen
 
J

Jonathan West

Change this line

Private Sub Document_Open()

to this

Sub AutoOpen()

if you do that, the macro will run for all documents based on the template
where the code is located. If you place the code in the normal.dot template,
it will run for *all* documents.


--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
 

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