Akash Deep Sharma
Akash Deep Sharma

Reputation: 29

Calling a macro from another workbook causes macros get skipped

I'm trying to perform the below operation from a workbook (Say A.xlsm):

  1. Opening another workbook (say B.xlsb)
  2. Calling a macro in B.xlsb from A.xlsm
  3. Save the workbook B.xlsb
  4. Close the workbook B.xlsb

Below is the code in A.xlsm:

Workbooks.Open(Filename:=B.xlsb).RunAutoMacros Which:=xlAutoOpen
Workbooks(B.xlsb).Activate
Windows(B.xlsb).Activate
Application.Run (B.xlsb& "!MyMacro")

Above all works fine, but a macro (Initialize, which is for initializing the ribbon object) gets skipped in B.xlsm which is should get called at the time of loading of the workbook B.xlsb. When I open it manually and then Save and close.

I see the macros Workbook_Open, Workbook_Activate and Initialize (this is configured in an XML to be called at the loading time) gets called in sequence.
But the same when I do from VBA then Workbook_Open and Workbook_Activate are called but Initialize gets skipped.

Image showing Initialize macro in B.xlsb

Upvotes: 2

Views: 165

Answers (1)

tuannv256
tuannv256

Reputation: 501

Workbook functions don't have function Initialize. Refer Workbook object

Upvotes: 1

Related Questions