Supaya macro otomatis kebukak yen file excell dibuka kudu nggawe macro “auto_open” lan “auto_close” supaya macro otomatis ketutup yen file excell ditutup.

Yen file excell dibukak bakal muncul menu item “Menu Anyar” ing menu “Tools”. Yen menu iki diklik bakal nglakokke macro “njajal”

Sub Auto_Open()
MenuBars(xlWorksheet).Menus(“Tools”).MenuItems.Add _
Caption:=”Menu Anyar”, _
OnAction:=ThisWorkbook.Name & “!Module1.njajal”, _
before:=1
End Sub

Ben macro langsung ketutup yen file excell ditutup.

Sub Auto_Close()
MenuBars(xlWorksheet).Menus(“Tools”). _
MenuItems(“Menu Anyar”).Delete
End Sub