<Excel VBA> Invoke VBA: Cannot run the macro 'PC_Exists_in_SAP'. The macro may not be available in this workbook or all macros may be disabled

I’ve enabled in trust settings. PFA snip for reference.


But it’s still giving issue.
FYI,
a. VBA script is being saved in notepad file with .vbs extension as well.
b. Enable All is being put in Excel application as well
c. Excel is being saved as .xlsx
d. VBA code I am trying to run:
Sub PC_Exists_in_SAP()
Columns(“A:B”).Select
Selection.Copy
Sheets("Mon Sheet 1 ").Select
Columns(“A:A”).Select
Selection.Insert Shift:=xlToRight
End Sub
Please help. Thanks in advance.

Hi

Error indicates that the macro that you are trying to run is not available in the workbook or that macros are disabled on the machine where you are running the script.

It could be like

  • The macro is in a different workbook than the one that you are trying to run the script in.
  • The macro was deleted from the workbook.
  • The macro was disabled in the workbook.

But the most common cause of this issue is related to macro security settings in Excel.

Macros may be disabled or set to a high security level on the machine where the automation is failing
Make sure this setting is enabled in others machine
Open an Empty excel or any excel file → Goto File-> Option ->Goto Trust Center → Trust Center Settings → Go to “Macro Settings” and choose a lower security level or enable macros.
Save it and restart excel

If this is done already but still if facing issue then ensure that the workbook (XLSB file) being accessed by your automation contains the macro named “Distribution file - Runall” as mentioned in the error message
Ensure that the XLSB file is in the expected location or in the expected sheet of the excel
Check this out

Check on these aspects and let us know for further clarification

Cheers @anjasing

@anjasing

in the macro settings try selecting the 4th option and check if that works

Also check in file blockign settings if it is blocked

cheers

M not sure if invoking VBA actually requires us to enable all macros (not recommended) one

@anjasing

Try it out…if it works then that is the issue if not…we can atleast diagnose it

cheers

I’ve already tried, it working with execute macro activity but not with invoke VBA