How to use macro activity

Execute Macro: Cannot run the macro ‘This workbook.macro1’. The macro may not be available in this workbook or all macros may be disabled.

when i run my macro i am getting this error
I have done file > options > trust center >enable all macro and trust access the VBA too but still i m getting this error .

and i m running this commands in notpad and exporting it to my vb ,these commands are running with my excel but its show me an error with uipath

Sub CreatDropDownList()


’ CreateDropDownList Macro


Range(“A1:D375”).Select
Range(“A1”).Activate

End Sub

Sub Macro1()

’ CreateDropDownList Macro

Range("D2").Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="H ,C , Cel"

End Sub

can anyone help
Regard

Hi @Raina_Ocean_Sanjay

Is the macro present in the excel file? (file extension would be .xlsm)

if yes, then use the Execute Macro activity

If no, then use the Invoke VBA activity.

Hi @Raina_Ocean_Sanjay

Have a look on it

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjCsMaY4tn5AhXqFLcAHZrDAN0QwqsBegQIBRAB&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DmGU6xxsqVWA&usg=AOvVaw27IRGKXySw9Dov0cQxCWCi

Regards
Gokul

The macro is in excel file and the extension of it is also xlsm
but still with excute macro it is throwing me an error
regards

@Raina_Ocean_Sanjay

Please share the screenshot of your workflow, also the properties of the execute macro activity

@Raina_Ocean_Sanjay Please go through the attached file for the basic implementation of execute macro

ExecuteMacro.zip (11.9 KB)


When you save your file is it .xlsx or is it .xlsm ?
It should be the 2nd one.

the excel save is in xlsm after executing the macro
Regards

Your exception tells me that you are trying to run the macro in the workbook that does not exist.
You can use “Get workbooks” activity to get a list of your all workbooks and then see if there was a typo in the property Invoke Macro

Hi,

Some things to follow before using Execute Macro activity:

  1. Enable macro from trust center settings in Excel app.
  2. Use execute macro activity inside Excel application scope.
  3. Keep .vbs as extension of macro file.

the sheets are there
Regards

already did this
Still i m getting an error
Regards ,

Can you do following steps?

Copy your vba script and paste it in demo.vbs.
Use excel application scope to open your excel file
Use Invoke VBA activity and pass “CreatDropDownList” to Entry method name parameter.

Thanks.

the process is running but it is now not creating a drop down

regards

Thank you for the solution :slight_smile:

Regards ,
Ocean

Pleasure is all mine.
Keep posting if you are having any doubts.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.