Control Ids


Excel

 Public Sub ListControlsIds() 
   Dim cbar As Office.CommandBar
   Dim ctl As CommandBarControl
   Dim iid As Integer
   Application.CommandBars("temporary").Delete
      Set cbar = Application.CommandBars.Add("temporary", msoBarTop, False, True)
   
   For iid = 1 To 4000
      On Error Resume Next
      Set ctl = cbar.Controls.Add(Id:=iid)
   Next iid
   
   iid = 1
   For Each ctl In cbar.Controls
      If InStr(ctl.Caption, "&New Slide") > 0 Then
         Debug.Print ctl.Caption
         Debug.Print ctl.Id
         iid = iid + 1
      End If
   Next ctl
   
   cbar.Delete
End Sub

PowerPoint

Public Sub ListControlsIds() 
   Dim cbar As Office.CommandBar
   Dim ctl As CommandBarControl
   Dim iid As Integer

   On Error Resume Next
   Application.CommandBars("temporary").Delete
   Set cbar = Application.CommandBars.Add("temporary", msoBarTop, False, True)
   
   For iid = 1 To 4000
      On Error Resume Next
      Set ctl = cbar.Controls.Add(Id:=iid)
   Next iid
   
   iid = 1
   For Each ctl In cbar.Controls
      If InStr(ctl.Caption, "&New Slide") > 0 Then
         Debug.Print ctl.Caption
         Debug.Print ctl.Id
         iid = iid + 1
      End If
   Next ctl
   
   cbar.Delete
End Sub

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext