Can macro/userform run depending on HOW workbook is opened?

G

grasping@straws

I'd like to show a userform (and/or run a macro) when I open my
Template Wizard database workbook...but NOT have it run when Excel
opens it in the background to copy new records or update existing
ones...any way to do this?

tm
 
D

Dave Peterson

If you put your code to show the form in Auto_open() (in a general module), then
that'll run when the workbook is opened manually.

If you open the workbook via code, it won't run (unless you run it explicitly,
see RunAutoMacros in VBA's help for more info).

Alternatively, you could put your code behind ThisWorkbook (workbook_open).

This code will run unless you stop it and you can stop it by disabling events:

application.enableevents = false
'your code to open the other workbook
application.enableevents = true
 
Top