VBA, MS Access MS Access в примерах

Удаление всех Custom (Пользовательских) Меню из приложения

Private Sub KillCustomMenus()
'Удаление всех Custom Меню
'--------------------------------------------------------------------------
Dim ibjApp As Application
Dim ibjComBar As Object

On Error GoTo KillCustomMenus_Err
    
    Set ibjApp = Application
    
    For Each ibjComBar In ibjApp.CommandBars
        
        If Mid(ibjComBar.NameLocal, 1, 7) = "Custom " Then
            Debug.Print ibjComBar.NameLocal & " Индекс:" & ibjComBar.Index
            CommandBars(ibjComBar.Index).Delete
        End If
    Next

KillCustomMenus_End:
    On Error Resume Next
    Set ibjApp = Nothing
    Set ibjComBar = Nothing
    Err.Clear
    Exit Sub

KillCustomMenus_Err:
    MsgBox "Error: " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
    "in Sub: KillCustomMenus in module: modMenuTools", vbCritical, "Error in Application"
    Err.Clear
    Resume KillCustomMenus_End
End Sub
Назад ToTop
L.E. 04.10.2021
Рейтинг@Mail.ru