Using Windows 10, Excel 2016. The code is in a Module.
The code worked when written in 2015. Now it throws errors. The text of the error messages is different from that in the other threads with the same error codes.
The code attempts to locate a button by its caption and delete it. There is only one button per worksheet.
DeleteShapesByCaption "Create a new Schedule of Values tab", wSht
The error always occur at the first occurance of Shp.Delete
RTE 404 Object Required or RTE -2147024809 (80070057) The specified value is out of range
Context:
The workbook has a worksheet which is a template. Once the template is filled in, it is copied for month 1. After the month 1 sheet is completed, the create_a_new_sheet_button is clicked to create a new sheet for month 2 and the create_a_new_sheet_button is supposed to be removed from the month 1 sheet. Each sheet only has one button.
I have used debug.print to confirm that the activesheet is the previous month's sheet.
I have modified cell formulae to reflect changes in legislation, but I don't think those changes are relevant because now even the original 2015 workbook produces the errors.
The code executes as expected in creating the month 1 sheet. The only difference is that the create_a_new_sheet button is not deleted from the template page.
I can change the caption and disable the button as an error free work around, but it would be preferable to delete it.
Bookmarks