Aquí tienes otra forma de hacerlo, creo que más elegante y sencilla.
He dejado comentado algunas líneas que utilicé para la depuración.
Cuento con tus reparos. ;-)
Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function AccessibleChildren Lib "oleacc" _
(ByVal paccContainer As Office.IAccessible, _
ByVal iChildStart As Long, _
ByVal cChildren As Long, _
ByRef rgvarChildren As Any, _
ByRef pcObtained As Long) As Long
Public Const CHILDID_SELF = 0&
' Public Const VT_I4 As Integer = 3
' Public Const NAVDIR_FIRSTCHILD = 7&
' Private Const NAVDIR_NEXT = 5&
Private Const S_OK = 0&
#Else
Private Declare Function AccessibleChildren Lib "oleacc" _
(ByVal paccContainer As Office.IAccessible, _
ByVal iChildStart As Long, _
ByVal cChildren As Long, _
ByRef rgvarChildren As Any, _
ByRef pcObtained As Long) As Long
Public Const CHILDID_SELF = 0&
' Public Const VT_I4 As Integer = 3
' Public Const NAVDIR_FIRSTCHILD = 7&
' Private Const NAVDIR_NEXT = 5&
Private Const S_OK = 0&
#End If
' Dim f As Integer
Private Sub Prueba()
Dim Portapapeles As IAccessible
Dim IsVis As Boolean
Set Portapapeles = Application.CommandBars("Office Clipboard")
IsVis = Portapapeles.Visible
If Not IsVis Then
' la barra del portapapeles tiene que estar abierta para que funcione
Portapapeles.Visible = True
DoEvents
End If
' f = 2
BorraPortapapelesOffice Portapapeles.accParent
Application.CommandBars("Office Clipboard").Visible = IsVis
End Sub
Private Sub BorraPortapapelesOffice(ByVal Acc As IAccessible)
Dim i As Long
Dim NumeroHijos As Long
' Dim H As Worksheet
' Set H = Worksheets("Hoja2")
NumeroHijos = Acc.accChildCount
If NumeroHijos > 0 Then
ReDim List(NumeroHijos - 1) As Variant
If AccessibleChildren(Acc, 0, NumeroHijos, List(0), NumeroHijos) = S_OK Then
If IsObject(List(i)) Then
For i = LBound(List) To UBound(List)
With List(i)
On Error Resume Next
' H.Cells(f, 1) = .accChildCount
' H.Cells(f, 2) = .accValue(CHILDID_SELF)
' H.Cells(f, 3) = .accName(CHILDID_SELF)
If .accName(CHILDID_SELF) = "Borrar todo" Then
.accDoDefaultAction (CHILDID_SELF)
Exit Sub
End If
' H.Cells(f, 4) = .accDescription(CHILDID_SELF)
On Error GoTo 0
' f = f + 1
End With
BorraPortapapelesOffice List(i)
Next
End If
End If
End If
End Sub