The macro may not be available in this workbook or all macros may be disabled even after modified trust center

Hi,

I am getting this error:

“The macro may not be available in this workbook or all macros may be disabled”

I have enabled “Trust access to the vba project model” and still, getting the same error.

Any help would be appreciated.

1 Like

May I. Know which activity is used buddy
And by the way
Happy birthday
Cheers @mesalcan

I am using “Invoke VBA” activity.

and Thanks! for both

@Palaniyappan

1 Like

Fine
I hope the file is not having any macro to be executed like it is not a macro enabled file .xlsm
—fine try to pass that excel file path as input to excel application scope and inside the scope use execute macro activity by passing the method in that activity property panel

That would work for sure
Cheers @mesalcan

Not sure I am getting what you are saying.

I have an invoke VBA activity within an excel scope, as per following image.

image

The excel file I am using, is a simple .xls
@Palaniyappan

1 Like

Yah that’s the reason
Usually a macro enabled file will be file extension .xlsm
As this is just a normal .xls excel file this error is popping up

Cheers @mesalcan

I have looked in how to enable macros in Excel on Microsoft and they can be enabled even on “.xls”. I have done that and the error still persist.

Thanks!

@Palaniyappan

.xls File can take macros only when we run explicitly using a vb script
and here in UiPath we use INVOKE VBA with excel application scope where in the property panel, we can mention the file path of a text file having the vb script and the method name

else if the excel itself has a macro in it, then the file extension would be like .xlsm

hope this would help you

Cheers @mesalcan

this is wrong. vba should be in .txt file. written in notepad.

1 Like

I am running a vb script within an excel application scope. There is no macro inside the excel file, but getting the error previously mentioned when invoking the vb script.

Thanks!

@Palaniyappan

The vb script has been created using Notepad++.

Thanks!

@Petar_Soce

Fine
may i know what error you were getting
Cheers @mesalcan

Cannot run the macro “function name”. The macro may not be available in this workbook or all macros may be disabled.

@Palaniyappan

1 Like

You have to change the file format you are invoking.
Your macro should be in .txt file
image

I have another process that calls the “vbs” without having issues; but I have been unable to find any difference, other than the one working is a “Sub” and mine is a “Function”.

@Petar_Soce

I changed to text file and getting same error.

@Petar_Soce

I struggled for quite some time with this.
If your code file has this at the top "Attribute VB_Name = “Module1” - remove it and just name the Sub to be the same as the EntryMethodName that you specified in the Invoke VBA file.
For example VBA File -
Sub Main()
Sheets(“Client Quote”).Tab.ColorIndex = 4
End Sub
image

1 Like

@mesalcan Have you resolved your issue ? I am having similar issue.

Guys, if anyone comes over this topic in the future, this happened to me and this is how I solved it.

When you open the VBA editor (By clicking ALT+F11, or go to Developer > Visual Basic):
image

You should delete all your modules from there and then run the Invoke VBA activity again.

5 Likes

Hi, you can write your VBA Codes into notepad as .txt format and you should run in Invoke VBA .txt file in Excel Application Scope. The problem is solved this way.