VBA Code Not Saving With Spreadsheet

smw_vba

New Member
Joined
Mar 3, 2022
Messages
2
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Situation:
I have a VBA program that builds a new compilation workbook from other Excel files. The new workbook contains some forms objects / event handlers and is saved "WBout.Close SaveChanges:=True" in a ".xlsm" file. The program works flawlessly when I execute on my home Win10 PC with Office 2013. When I port the program over to my work laptop also Win10 but using Office 365 the VBA code in the compilation workbook is not saved with the compilation spreadsheet. If I set a breakpoint on / before the save command at the end of my program the compilation spreadsheet VBA code is in the workbook. If I manually save the spreadsheet then exit the VBA program the compilation spreadsheet is correct and contains the VBA code. If I do the same but instead of exiting I continue to the end of the program the VBA code is cleared.

My ideas for possible issues:
1) A preferences difference between Office 2013 and Office 365
2) An operational difference between Office 2013 and Office 365
3) A permissions issue on my work laptop

Any ideas on where to look?

Thanks
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

6StringJazzer

Well-known Member
Joined
Jan 27, 2010
Messages
2,386
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
First we need to see your code. Is the file being saved without VBA being saved as a .xlsm file? I know you said it was on your home machine but what about on the work laptop?
 

smw_vba

New Member
Joined
Mar 3, 2022
Messages
2
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
First we need to see your code. Is the file being saved without VBA being saved as a .xlsm file? I know you said it was on your home machine but what about on the work laptop?
Hi Jeff,
The code is ~600 lines so most is probably not relevant.
I save once near the start of the program"
WBout.SaveAs Filename:=outfile, FileFormat:=xlOpenXMLWorkbookMacroEnabled
and then at the end:
WBout.Close SaveChanges:=True
The code is copied from one computer to the other. Doing a break and saving the open workbook saves and exiting the program, the code is saved.

I changed the code to only save once at the bottom and it now saves the VBA code. I probably did the first save during early development and did not back it out.

Steve
 
Solution

Forum statistics

Threads
1,176,103
Messages
5,901,398
Members
434,890
Latest member
creativimama

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top