Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel 2016 triggers undo upon save bug?

Tags:

c#

excel

vb.net

vba

Excel 2016 seems to trigger a programmatically added undo level upon saving, which does not happen in earlier versions of Excel (2013, 2010, and 2007). To reproduce this apparent bug, open a new workbook and save it as a macro-enabled workbook (.xlsm file). Paste the following code into the ThisWorkbook module:

Option Explicit
Public WithEvents App As Application
Private Sub Workbook_Open()
    Set App = Application
End Sub
Private Sub App_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Application.OnUndo "foo", "modTest.Undo"
End Sub

Then, insert a new module named modTest and paste the following code:

Public Sub Undo()
    MsgBox "This is the Excel 2016 bug."
End Sub

Finally, save the workbook and reopen it. Enter any value in any cell to trigger the Application.SheetChange event. Save the workbook (you may need to do this twice, for some reason), and the message in modTest will appear.

Can anyone explain what may be going on here, and/or how to work around this problem? If this is indeed a bug, what is the best way to report it to Microsoft?

This code is VBA, but since this problem affects VSTO add-ins written in VB.NET and C#, too, I am including those tags.

like image 450
OfficeAddinDev Avatar asked Jun 24 '16 10:06

OfficeAddinDev


1 Answers

We have confirmed via testing and direct communication with MS software engineers and support staff that this bug is fixed in Office builds released late July / early August 2016.

like image 122
OfficeAddinDev Avatar answered Oct 20 '22 19:10

OfficeAddinDev