繁体   English   中英

Excel加载项:如何删除宏热键

[英]Excel Add-in: How to remove macro hotkey

如何从没有出现在“工具”>“宏”>“宏”中的宏中删除热键?

我安装了一个加载项,并且Excel已自动为其分配了热键“ CTRL + U”。 我希望Ctrl + U保留其原始功能,在单元格中加下划线。

请注意,加载项(.xla)是从Excel菜单栏中运行的-在“工具”>“宏”>“宏”中看不到,因此无法从“工具”>“宏”>“宏”>“选项”更改热键。

我在各种版本的Excel中都使用了此加载项,因此,如果说明因版本而异,请告诉我。

谢谢!

附加信息:加载项(我写的)未设置快捷键。 它是由Excel单方面分配的。

Private Sub Workbook_Open()
  Set XLApp = New clsExcelEvents  ' start monitoring events
  Set SC = New clsStatementConverter  ' initialize some variables
  If CountVisibleWorkbooks > 0 Then
     Call SetMenuOptions  ' update the menu bar
  End If  
End Sub

SetMenuOptions():

Public Sub SetMenuOptions(Optional IsDisableOptions As Boolean = False)
' Set the enabled/disabled status of the "Convert to QB" menu options
'
' If config files exist in the same directory as the current workbook,
'   enable the menu options. Otherwise, disable.
' To force the sub-menu to be disabled (last visible workbook is
'   being closed), set IsDisableOptions to True
'
On Error GoTo Error_Handler
Dim blnEnableOptions As Boolean
' Default to menu options not enabled
blnEnableOptions = False
Application.ScreenUpdating = False
'
' Is a visible workbook open?
If (Not IsDisableOptions) And (Not ActiveWorkbook Is Nothing) Then
  ' Yes, there is an active workbook. Are any of my config files in
  ' the same directory as this workbook?
  Dim aryFiles() As String
  aryFiles = GetListOfConfigFiles(ActiveWorkbook.Path)
  ' Are there any files? (is the array initialized?)
  If IsInitializedArray(aryFiles) Then
    If (UBound(aryFiles) > 0) Then
      ' Yes, there is at least one config file
      blnEnableOptions = True
    End If
  End If
End If
'
' If disable: set all options to disabled, except for the "About..."
' If enable: (1) set all _installed_ converters to enabled (if a converter
'                has not been installed, don't enable it)
'            (2) enable all other menu options
'            (3) rebuild the list of config files
Dim cbcMenu As CommandBar
Dim cbcConverterMenu As CommandBarControl
Dim cbcViewConfigMenu As CommandBarControl
Dim cbcControl As CommandBarControl
Dim blnMenuIsInstalled As Boolean
'
Set cbcMenu = Application.CommandBars("Worksheet Menu Bar")
'
' Is the Converter menu installed?
' This Sub is called after the menu is deleted (when the add-in is uninstalled), so
' trap for the menu not existing before enabling/disabling the sub-menu options, below
blnMenuIsInstalled = False
For Each cbcControl In cbcMenu.Controls
  If cbcControl.Caption = "&Convert to QB" Then
    blnMenuIsInstalled = True
  End If
Next
'
If blnMenuIsInstalled Then
  Set cbcConverterMenu = cbcMenu.Controls("&Convert to QB")
  Set cbcViewConfigMenu = cbcConverterMenu.Controls("View config...")
  '
  ' Step 1: Disable/Enable the controls for this menu
  '   If Disable, then disable all controls except "About"
  '   If Enable, then enable all controls for which converters are installed
  For Each cbcControl In cbcConverterMenu.Controls
    ' Keep "About" enabled
    If cbcControl.Caption <> "About..." Then
      cbcControl.Enabled = blnEnableOptions
    End If
  Next
  '
  ' Step 2: Rebuild the list of config files
  If blnEnableOptions Then
    ' If a system configuration file exists in the ActiveWorkbook directory, read it
    SC.ConfigFilePath = ActiveWorkbook.Path & Application.PathSeparator
    ' Test for the system config filename
    SC.SystemConfigFilename = GetConfigFilename(SC, True)
    ' Was a system config file found?
    If SC.SystemConfigFilename <> "" Then
      ' Yes, get user settings from the config file
      Call GetConfigSettings(SC.ConfigFilePath, SC.SystemConfigFilename)
    End If
    '
    ' Delete the existing menu options to view config files
    For Each cbcControl In cbcViewConfigMenu.Controls
      cbcControl.Delete
    Next
    ' Add a menu option to view for each config file
    Dim lCtr As Long, strMenuItem As String
    For lCtr = 1 To UBound(aryFiles)
      strMenuItem = aryFiles(lCtr)
      With cbcViewConfigMenu
        .Controls.Add(type:=msoControlButton).Caption = strMenuItem
        .Controls(strMenuItem).OnAction = "'ThisWorkbook.ViewTextFile """ & strMenuItem & """'"
      End With
    Next
  End If
End If
Application.ScreenUpdating = True
GoTo Exit_Handler

Error_Handler:
  MsgBox Err.Number, "SetMenuOptions", Err.Description, Err.HelpFile, Err.HelpContext
  GoTo Exit_Handler

Exit_Handler:
  Exit Sub

End Sub

单击文件>选项>自定义功能区,然后按照以下说明进行添加或删除或快捷方式: https : //support.office.com/zh-cn/article/customize-keyboard-shortcuts-9a92343e-a781-4d5a-92f1-0f32e3ba5b4d

如果创建了功能区,则快捷方式应显示在“自定义功能区”选项卡下。 如果所有其他方法均失败,则可以始终将原始快捷方式重新分配给其他内容,并且不与新的Excel快捷方式分配冲突。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM