I'm having troubles naming command buttons that I paste into a row with code.
A portion of the code is included.

I search through some rows and find the last row containing a command button in it.
[vba]For Position = 198 To 500
Worksheets("Test Plans").Shapes("cmdESD" & Position).Select
' MsgBox ActiveSheet.Shapes("cmdESD" & Position).TopLeftCell.row
If Err.Number = 0 Then
'the object exists
Else
'the object doesn't exist
ObjLocation = ActiveSheet.Shapes("cmdESD" & Position - 1).TopLeftCell.row
Exit For
End If
Next Position [/vba]

Next I copy the row to capture all the formating on the row.
[vba]
'Copy row
Rows(ObjLocation).Select
Selection.Copy[/vba]

I then paste into the next row
[vba]
'Paste row
Range("A" & ObjLocation + 1).Select
Worksheets("Test Plans").Paste [/vba]

I then copy the first of two command buttons in the copied row. Buttons are named cmdWord200 and cmdESD200, where 200 is the row number they are on.

[vba]
Worksheets("Test Plans").Shapes("cmdWord" & ObjLocation).Select
Application.CutCopyMode = False
Selection.Copy [/vba]

I then paste the copied button into the pasted row

[vba]
Range("C" & ObjLocation + 1).Select
Worksheets("Test Plans").Paste 'Select the pasted object
'Name the selected object
Worksheets("Test Plans").Shapes("CommandButton1").Name = "cmdWord" & CStr(ObjLocation + 1) [/vba]

This is repeated for the second command button.

[vba]
Worksheets("Test Plans").Shapes("cmdESD" & ObjLocation).Select
Application.CutCopyMode = False
Selection.Copy
Range("C" & ObjLocation + 1).Select
Worksheets("Test Plans").Paste
'Rename command buttons
Worksheets("Test Plans").Shapes("CommandButton2").Name = "cmdESD" & CStr(ObjLocation + 1)[/vba]

The problem is that the first command button is never renamed, the second one always seems to work.

When I step through the code I get the message "Can't Enter Break Mode At this time".

I can't find any duplicate names and I can name the button manually.

Am I missing something?

Thanks!