Using ExecuteExcel4Macro to run Workbook_SheetActivate

zelarra

Board Regular
Joined
Jan 2, 2021
Messages
70
Office Version
  1. 365
Platform
  1. Windows
Hi guys.

I've prepared a screenshot for you so you can understand what I want to achieve, if it's possible:

1722704374124.png


Let's start with the red lines. I have a procedure in a module called mdlCodigos of the personal macro book PERSONAL.XLSB.

In this procedure, I want to mention the Workbook_SheetActivate procedure of the ThisWorkbook module of the open book Farmacia.xlsm (I'll mark it in green).

And I used this code:

VBA Code:
Private Sub Prueba()

    Dim Ws As Object

    Set Ws = Worksheets(ActiveSheet.Name)
    
    ExecuteExcel4Macro "Farmacia.xlsm!ThisWorkbook.Workbook_SheetActivate(""" & Ws.Name & """)"

End Sub

However, it doesn't work for me.

I wanted to ask someone to tell me how to write the code, then.

Thank you very much.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
ExecuteExcel4Macro is a special method intended to run an Excel 4.0 macro (long obsolete). It should not be used in the way you are trying to use it since Workbook_SheetActivate is not an Excel 4 macro. Perhaps if you could explain more about what you are trying to test.
 
Upvote 1
Solution
Thank you very much, guys.

In this particular case, my goal was not to try to illustrate what I wanted to achieve, but rather to find out if what I proposed could be done or not, in order to learn a little more about ExecuteExcel4Macro.

As I said, I really appreciate your contributions.

Regards.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top