title: Why can't I edit a commandbar control in Excel 2013 with VBA?
body: <p>I'm trying to make my own drill-through action for PivotTable by means of VBA.
  The action will be called from context menu of a PivotTable from <strong>Additional Actions</strong>.
  I want to put my button under <strong>Additional Actions</strong> control of <strong>PivotTable Context Menu</strong> command bar.
  The point is that by default <strong>Additional Actions</strong> already contains <strong>(No Actions Defined)</strong> item.
  So, I want to remove this <strong>(No Actions Defined)</strong> after adding my button, but nothing works.
  I cannot even change any property of <strong>(No Actions Defined)</strong> control, like Caption, Visible, etc.
  What might be the reason, and what is the workaround?
  Here is my code so far (you can put it under Workbook_SheetBeforeRightClick, for example, and then test with any Pivot Table in that workbook):</p>
  
  <pre><code>Dim PCell                   As PivotCell
  Dim PComBar                 As CommandBar
  Dim PControl                As CommandBarControl
  Dim DControl                As CommandBarControl
  Dim BControl                As CommandBarControl
  Dim IsFromPivotTable        As Boolean
  
  IsFromPivotTable = False
  On Error GoTo NotFromPivot
  Set PCell = Target.PivotCell
  IsFromPivotTable = True
  NotFromPivot:
  On Error GoTo 0
  If IsFromPivotTable Then
      Set PComBar = Application.CommandBars("PivotTable Context Menu")
      Set PControl = PComBar.Controls("Additional Actions")
      On Error Resume Next
      With PControl
          Call .Controls("My Drillthrough Action").Delete
          .Enabled = True
      End With
      On Error GoTo 0
      Set DControl = PControl.Controls.Add(Type:=msoControlButton, Temporary:=True, Before:=1)
      With DControl
          .Style = msoButtonIconAndCaption
          .Caption = "My Drillthrough Action"
          .FaceId = 786
      End With
      On Error Resume Next
          Set BControl = PControl.Controls("(No Actions Defined)")
          With BControl 'This does not work and throws error if do not suppress with On Error
              .Enabled = True
              .Visible = False
              .Caption = "Hello there"
          End With
      On Error GoTo 0
  End If
  </code></pre>
  
  <p>So, the last section <strong>With BControl ... End With</strong> does not work at all, and throws an error "Automation Error".
  I can successfully edit <strong>Additional Actions</strong> itself, like enable it, but I would like to get rid of <strong>(No Actions Defined)</strong> control, or replace it with my own.
  Note, that <strong>Call .Controls("(No Actions Defined)").Delete</strong> does not work either.
  How can I do that?
  I tried to google the problem, but no luck...</p>