About EasyMorph Tutorials & Examples Web-help

Problem running a macro in .xlsb file

Hi everyone,

I am trying to run a loop a macro in a list of files. But the point is that the macro is on the Excel Toolbars File extension .xlsb, as far as I tried I cannot use this file extension to run the macro from this file in EasyMorph.

I tried to include the name of the file as parameter in EasyMorph and is not working.

How can I loop the 50 files (.xlsx without the macro) and execute this macro saved on the .xlsb file???

Thank you all in advance!!

Hi Jesus and welcome to the Community!

Did you try re-saving the .xlsb file as .xlsm? Also, can you post a screenshot of your “Excel command” action?

Hello, Jesus_M-A, and Dmitry.

You can use the Excel Command to run a macro in an .xlsb file. It’s not part of the default Excel file extension selections, however.

When selecting your Excel file containing the macro(s) to run, to the right of the File name box where it shows "Excel files (*.xlsx; *.xls, *.xlsm), click the dropdown and select “All files”, then browse to and select the .xlsb file. I just tried that on one of my own workflows to confirm, and it worked fine.

Let us know if you have any issues on your end with this.
Welcome to the Community!

Thank you CraigT and Dmitry!!

I have tried first the Dmitry solution and it´s working as need, I have move the macro code to another .xlsm file and call from EasyMorph this new file.

But I will try also your point CraigT.

Thank you both again!!! Great and very fast community!!!

I am not sure… I also want to run some unique macro on many xlsx files. The macro is currently saved in my “personal.xlsb” file.
So, how do you call and run a macro that isn’t in your xlsx files on these files?

Hi, Nicolas.

If the macro you want to run on the various xlsx files is stored in your Personal.xlsb file, you’ll need to navigate to that in the Excel Command action. You’ll find Personal.xlsb stored in the following folder:

C:\Users\{your user name}\AppData\Roaming\Microsoft\Excel\XLSTART

(Note: “AppData” is hidden by default, so if you don’t see it, you’ll need to “show hidden files/folders” in the File Explorer settings.)

When browsing in the Excel Command action, change the file type to “All files (.)” from the default “Excel files (*.xlsx; *.xls; *.xslm)” setting - in the bottom-right corner of the browser window. (pic attached). EasyMorph doesn’t “see” xlsb, by default.

If your macro runs through the individual xlsx files itself, you’re set. Just run the macro as described above.

If, however, you’re talking about running the macro across a number of different xlxs files (i.e., the macro affects one file at a time, and you want to “pass” the individual xlsx files to it within EasyMorph), you’ll need to set up an iteration to pass in the list of xlsx files. Pass the xlsx filesnames into the iterated workflow as a parameter, and have the Excel Command pass it in as an argument. You’ll need to have the macro set up to receive this argument to use within its code. i.e., “Sub MySub(filename)”.

Hopefully, I’ve covered what you’re looking to do. If not, reply back, or Message me. There are a number of ways to do this. Happy to help. :grin:

-Craig

image

1 Like

Ok, I got it. I have finally used a separate .xlsx file with this code below and I passed the parameters through an “Excel” action in a “Iterate Table” action. Thanks !


Sub UnProtect(filePath As String, pwd As String)

booltemp = Application.ScreenUpdating

Application.DisplayAlerts = False
wb.Application.EnableEvents = False

Set wb = Workbooks.Open(filePath)

nbFeuilles = wb.Sheets.Count

For I = 1 To nbFeuilles
Sheets(I).Visible = xlSheetVisible
Sheets(I).UnProtect pwd
Sheets(I).ScrollArea = “”
Next I

wb.Close True

Application.ScreenUpdating = booltemp
Application.DisplayAlerts = True

End Sub


Awesome. Glad to hear it worked out, Nicolas! :+1:

To learn more about EasyMorph visit easymorph.com.