Macro to run upon Workbook opening

  • Thread starter Thread starter James C
  • Start date Start date
J

James C

New w/ macros.

I want one that does the following:

(1) I open the workbook it is stored in.
(2) It prompts me w/ a pop-up window: "Print and Close?" and 2 button
[YES] [NO]
(3) If I select YES, self evident. If I select NO, pop-up windo
closes.

Thanks in advance for the code.

- Ji
 
There are lots of options when you print--one worksheet, all the worksheets,
only a few (but not all), print only a certain selection....

Since there's so much that you could mean, you can record a macro when you print
what you want and how you want.

Then add it to this routine:

Option Explicit
Sub auto_open()
Dim resp As Long

resp = MsgBox(Prompt:="Print and close", Buttons:=vbYesNo)

If resp = vbNo Then
Exit Sub
End If

'paste your code that prints what you want


ThisWorkbook.Close savechanges:=False

End Sub



James said:
New w/ macros.

I want one that does the following:

(1) I open the workbook it is stored in.
(2) It prompts me w/ a pop-up window: "Print and Close?" and 2 buttons
[YES] [NO]
(3) If I select YES, self evident. If I select NO, pop-up window
closes.

Thanks in advance for the code.

- Jim
 
Back
Top