My company is upgrading computers and Office from 2010 to 2016. A workbook had VBA code (created via macro, so probably not as optimized as possible) to update data in a form on a sheet from a table, save the values in the form, and then copy that sheet to a new workbook using the data to save it with a unique filename. When it finished saving the new workbook, the code looped to the next record in the source workbook and repeated those steps until it reached the end of the list. Now that we have switched to Excel 2016, the code runs fine until it tries to copy the sheet with the form to a new workbook. It opens the new workbook and closes the source one which interrupts the code execution. As far as I can tell there were no other changes except moving from Win7 and Excel 2010 to Win10 and Excel 2016. Any thoughts why the source workbook would now suddenly be closing?
VBA Code:
Sheets("Form").Copy
ChDir strNewFilePath
ActiveWorkbook.SaveAs Filename:=strNewFilePath & strNewFileName, FileFormat _
:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.WindowState = xlNormal
With ActiveWindow
.Top = 49
.Left = 85
End With
Windows("OriginalForm.xlsm").Activate
With ActiveWindow
.Top = -0.5
.Left = 7.75
End With
Workbooks(strNewFileName).Close
ActiveWindow.WindowState = xlMaximized