Forum Discussion
perkin_warbeck
Mar 03, 2024Brass Contributor
Porting an Excel VBA application from Windows to Mac
I have Office 365 on a PC running Windows 11 and on a Mac Mini running Sonoma. I develop on Widows. After testing thoroughly, I copy the .xlsm file over to Mac for testing there. I have been doing th...
- Mar 05, 2024The only tool I know of only works in 32 bit Office. You can clean a project manually like this:
- Save-as the file as xlsx (yes, the VBA code is lost, this is on purpose)
- Close and reopen the newly saved file and the original one with the code
- Drag all modules, userform and class modules from the xlsm to the xlsx
- Copy code from all sheet modules to the appropriate sheet modules of the xlsx
- Copy code in ThisWorkbook too.
- Make sure the correct references are set
- Save As the xlsx to xlsm
You could also use this tool to copy the VBA project from the xlsm to the xlsx: https://jkp-ads.com/download.asp#CopyVBAProject
perkin_warbeck
Mar 04, 2024Brass Contributor
How do you recommend cleaning the project? Is there a tool you recommend?
JKPieterse
Mar 05, 2024Silver Contributor
The only tool I know of only works in 32 bit Office. You can clean a project manually like this:
- Save-as the file as xlsx (yes, the VBA code is lost, this is on purpose)
- Close and reopen the newly saved file and the original one with the code
- Drag all modules, userform and class modules from the xlsm to the xlsx
- Copy code from all sheet modules to the appropriate sheet modules of the xlsx
- Copy code in ThisWorkbook too.
- Make sure the correct references are set
- Save As the xlsx to xlsm
You could also use this tool to copy the VBA project from the xlsm to the xlsx: https://jkp-ads.com/download.asp#CopyVBAProject
- Save-as the file as xlsx (yes, the VBA code is lost, this is on purpose)
- Close and reopen the newly saved file and the original one with the code
- Drag all modules, userform and class modules from the xlsm to the xlsx
- Copy code from all sheet modules to the appropriate sheet modules of the xlsx
- Copy code in ThisWorkbook too.
- Make sure the correct references are set
- Save As the xlsx to xlsm
You could also use this tool to copy the VBA project from the xlsm to the xlsx: https://jkp-ads.com/download.asp#CopyVBAProject
- perkin_warbeckMar 05, 2024Brass ContributorI installed your CopyVBAProject Add-In in an otherwise empty workbook which I called Cleaner.xlsx. I opened the Source workbbok (an .xlsm) and the Target workbook (an .xlsx) and then clicked on the Add-In. In the user form, I selected the source workbook from the dropdown menu. But as soon as I clicked the Target workbook, the form code runs (I was not given a chance to click OK) and hit an error which causes execution to Stop with Err.Number = 1004. The line that causes the error is
```
For Each oComp in SourceBook.VBProject.VBComponents
```
By the way, the target workbook is the same as the source workbook, but was saved as an .xlsx to remove all VBA code, as you suggested.- JKPieterseMar 06, 2024Silver ContributorYou must turn on "Allow Access to the VBAProject object model" in Excel Options, Trust center, Trust center settings, Macro settings.
- perkin_warbeckMar 05, 2024Brass ContributorThank you for your suggestion, and for the link to CopyVBAProject. It sounds like a very sensible approach. I will try it.