Tibo
Tibo

Reputation: 393

VBA : Detect a change of Activeworkbook

I have a XLA AddIn macro with a main menu Userform. I need to enable/disable boutons on this menu userform according to the Activeworkbook.

My problem is that I don't know how to update the Userform when the user change or close the Activeworkbook.

I do have a UserForm_Activate, which update the Userform. But that event is not triggered when the user close the Activeworkbook then click on the Userform.

I would need to update the Userform either :

How would you proceed ?

Upvotes: 0

Views: 384

Answers (1)

Excel Developers
Excel Developers

Reputation: 2825

In the ThisWorkbook module of your xla:

Private WithEvents xlApp as Excel.Application

You will then see that xlApp has events such as WorkbookActivate and WorkbookDeactivate etc.

Upvotes: 2

Related Questions