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 you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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?
 
Upvote 0
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
 
Upvote 0
Solution

Forum statistics

Threads
1,215,030
Messages
6,122,762
Members
449,095
Latest member
m_smith_solihull

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
Back
Top