New run time errors in older code 1004, 424, -2147024809 (80070057)

Neil Humphries

New Member
Joined
Aug 1, 2018
Messages
1
Windows 10, Excel 2016 The code is in a Module.


Three years ago, this code worked. Now it throws errors. Thetext of the error messages is different from that in the other threads I have seen with thesame error codes.

The code attempts to locate a button and delete it. There isonly one button per worksheet.



DeleteShapesByCaption "Create a new Schedule of Valuestab", wSht

Sub DeleteShapesByCaption( _
ByVal Caption AsString, _
Optional ByVal WSAs Worksheet = Nothing)
Dim Shp As Shape
If WS Is NothingThen Set WS = ActiveSheet
WS.UnprotectProtect_Password
For Each Shp InWS.Shapes
'What kind ofshape is it?
Select CaseShp.Type
CasemsoOLEControlObject
'May be acommandbutton
IfShp.OLEFormat.Object.Object.Caption = Caption Then
Shp.Delete 'This is where the error occurs
End If
Exit For
CasemsoFormControl
'May be abutton
IfShp.OLEFormat.Object.Caption = Caption Then Shp.Delete
End Select
Next
wSht.ProtectProtect_Password
End Sub

The error always occur at Shp.Delete
RTE 404 Object Required
RTE -2147024809 (80070057) The specified value is out ofrange

Context:
The workbook has a worksheet which is a template. Once thetemplate is filled in, it is copied for month 1. After the month 1 sheet iscompleted, the create a new sheet button is clicked to create a new sheet formonth 2 and the create a new sheet button is supposed to be removed from themonth 1 sheet. Each sheet only has one button.

I have used debug.print to confirm that the activesheet isthe previous month's sheet.

I have a version which moves from the back of the shapes collection to the front, but I still get the same -2147024809 (80070057) run time error with the same msg text.

This code worked properly in 2015. I have modified cellformulae to reflect changes in legislation, but I don't think those changes arerelevant because now even the 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 thetemplate page.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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