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

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

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

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

KillCustomMenus_End:
    On Error Resume Next
    Set A = Nothing
    Set Q = Nothing
    
    Err.Clear
    Exit Sub

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