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

  • Thread starter Thread starter grasping@straws
  • Start date Start date
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
 
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
 

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

Back
Top