I created an excel file where I added some buttons that I connected to different macros. I want to send this excel file to a collegue but when he opens this file the button gives an error:
Cannot run the macro "macro-name". The macro may not be available in this workbook or all macros may be disabled.
Is there a way to include or insert macro's inside the excel file?
[I use Microsoft Office Professional Plus 2010]
Found the answer myself, sorry:
Save as.. "Excel Macro-Enabled Workbook (*.xlsm)
Related
I have searched on the internet to see if I can find any references to these problems without success.
Occasionally, in Excel 2016 or Excel 2019 I open a macro-enabled workbook and discover all macros within the file have disappeared. This is despite enabling the macros when the workbook is opened. I determine there are no macros available by selecting Macros on the Developer Tab. No macros will appear in the macro dialog box. In addition, although a number of macros are linked to buttons within the file, I will try to use these and none will work.
If I save, close and re-open the workbook in either of these versions of Excel the macros still do not reappear. However, if I re-open the file in Excel 2010 the macros are available with all working as intended. If I save the file in Excel 2010, close it and then reopen it in Excel 2016 or Excel 2019 the macros will have reappeared.
Occasionally, and again in Excel 2016 or Excel 2019, when I open one of my more complex, macro-enabled files it will not open correctly and instead Excel indicates it is corrupted and requires repairs. I do not allow Excel to make the repairs and instead close the file, reboot Excel and try reopening the file. Again, Excel will indicate the file is corrupted and attempt repairs which are not accepted. However, if I switch to Excel 2010 and open the same file no problems are encountered with the file opening normally. Once it has opened, if I then save the file in Excel 2010 and close it, the file will then open normally in Excel 2016 or Excel 2019.
Might you have an answer to why this is happening?
I have a vba code in my .xlsm excel file. When i edit it online, my code does not work. But it works when i have been editing it in Work book.
Why is this so?
The vba code contains a code for stoping duplicate value entry for a column in excel
Short answer is that you can open workbooks containing macros online but you can't do anything with the code.
Work with macros in Excel Online
Although you can't work with macros in Excel Online, you can open a
workbook that contains macros—though you won't be able to see the
macros. You can edit the worksheets and save a workbook containing
macros in Excel Online. The macros will remain in the workbook, and
you open the workbook in the Excel desktop application to view and
edit the macros.
Bottom line: Use Excel desktop application to work with macros.
You can vote for it as a feature here:
Developer tab, macros, custom add-ins for online Excel
I have a VBA macro enabled excel .xlsm file uploaded in oneDrive. The macros run automatically when you open the excel in desktop. Though we cannot operate on macros in online excel, will the auto macros get executed automatically if you open it online.
All the macros operate on excel cells, Is refreshing excel session thru excel graph API equivalent to open the excel?
This is the answer from Microsoft:
"Currently, you can't work with macros in Excel Online."
https://support.office.com/en-gb/article/Work-with-macros-in-Excel-Online-98784ad0-898c-43aa-a1da-4f0fb5014343
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_other-mso_online/macro-enabled-excel-files-in-excel-online/00e982dc-688a-47ee-abe7-4d1f01a4ca04
https://technet.microsoft.com/en-us/library/excel-online-service-description.aspx
I make a lot of workbooks where there is no data in the workbooks themselves, but there are macros and forms attached. I generally format these in .xlsb or occasionally .xlsm file format, but I'm wondering if there is a format where there is no actual workbook attached. Just like a file you can open in Excel that will launch the macro?
It just seems pretty inefficient to include a blank workbook that I just autohide on load.
Depending on the version of Excel, when you load up Excel it automatically opens a Personal workbook which isn't visible.
Normally this is created when you record a macro and close all windows. It will then ask you to save it to the file. I would then set up shortcuts for the Macros.
I have a reasonably complex macro that I need to run on multiple different excel sheets, this macro is updated periodically and whenever a change is made its necessary to change it in each individual excel sheet. is there a way to get each excel document to refer to the one macro?
for example if i had a hierarchy like this:
DOCUMENTS:
-xlsheet1.xls
-xlsheet3.xls
-xlsheet2.xls
MACROS:
-macro1.bas
where there was a button in each sheet that ran macro1 when clicked.
I would recommend either moving that macro to your personal file or create an Add-In
Working with Personal File
Topic: Create and save all your macros in a single workbook
Link: https://support.microsoft.com/en-us/office/create-and-save-all-your-macros-in-a-single-workbook-66c97ab3-11c2-44db-b021-ae005a9bc790
Quote from the above link:
When you first create a macro in a workbook, it works only in that workbook. But what if you want to use the macro in other workbooks? To make your macros available every time you open Excel, you can create them in a workbook called Personal.xlsb. That’s a hidden workbook stored on your computer, which opens in the background every time you open Excel.
Creating an Add-In
Topic: Creating Excel Add-ins
Link: http://www.ozgrid.com/VBA/excel-add-in-create.htm
Quote from the above link:
I am often asked by users 'what is the best way to distribute their macros?' My answer, is without doubt via an Excel Add-in. After all, this is what Add-ins are for. For those that are not sure what an Excel add-in is, it's is nothing more than an Excel Workbook that has been saved as an Add-in, File>Save as \ Microsoft Excel Add-in (*.xla). Once saved and re-opened the Workbook will be hidden and can only be seen in the "Project Explorer" via the Visual Basic Editor. It is NOT hidden in the same way as the Personal.xls as this can be seen (and made visible) via Windows>Unhide.
The Personal file is good for having a macro across any number of workbooks on a single computer. In a networked environment with multiple users, you could simulate the Personal file by having a single workbook with your macros in it and coding all other workbooks to open and hide this workbook when they start up.