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

Excel加载项:如何删除宏热键,excel,add-in,assign,Excel,Add In,Assign,如何从“工具”>“宏”>“宏”中未显示的宏中删除热键 我安装了一个外接程序,Excel自动将热键“CTRL+U”分配给它。我希望Ctrl+U保留其原始功能,在单元格中的文本下划线 请注意,外接程序(.xla)是从Excel菜单栏运行的--它在“工具”>“宏”>“宏”中不可见,因此无法从“工具”>“宏”>“宏”>“选项”更改热键 我在不同版本的Excel中使用此加载项,因此如果说明因版本而异,请告知我 谢谢大家! 附加信息:外接程序(我编写的)没有设置快捷键。它是由Excel单方面指定的 Priv

如何从“工具”>“宏”>“宏”中未显示的宏中删除热键

我安装了一个外接程序,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子集合menuOptions(可选IsDisableOptions为布尔值=False)
'设置“转换为QB”菜单选项的启用/禁用状态
'
'如果配置文件与当前工作簿位于同一目录中,
'启用菜单选项。否则,禁用。
'强制禁用子菜单(最后可见的工作簿为
'正在关闭),将IsDisableOptions设置为True
'
关于错误转到错误处理程序
将blnEnableOptions设置为布尔值
'默认菜单选项未启用
blnEnableOptions=False
Application.ScreenUpdating=False
'
'可见工作簿是否打开?
如果(非IsDisableOptions)和(非Active工作簿为Nothing),则
'是,有一个活动工作簿。我的任何配置文件都在
'与此工作簿的目录相同吗?
将文件()设置为字符串
aryFiles=GetListOfConfigFiles(ActiveWorkbook.Path)
“有文件吗?(数组是否已初始化?)
如果IsInitializedArray(aryFiles),则
如果(UBound(aryFiles)>0,则
'是,至少有一个配置文件
blnEnableOptions=True
如果结束
如果结束
如果结束
'
'如果禁用:将所有选项设置为禁用,除了“关于…”
'如果启用:(1)将所有已安装的转换器设置为启用(如果是转换器
'尚未安装,请不要启用它)
'(2)启用所有其他菜单选项
'(3)重新生成配置文件列表
将CBC菜单设置为命令栏
将cbcConverterMenu设置为CommandBarControl
Dim cbcViewConfigMenu作为CommandBarControl
Dim CBC控件作为CommandBarControl
Dim BLNMenue安装为布尔值
'
设置cbcMenu=Application.commandbar(“工作表菜单栏”)
'
'是否安装了转换器菜单?
'删除菜单后(卸载外接程序时)调用此子项,因此
'在启用/禁用下面的子菜单选项之前,菜单的陷阱不存在
BLNMENUISTALLED=False
对于cbcMenu.Controls中的每个CBCCONTROLS
如果cbcControl.Caption=“&Convert to QB”,则
BLNMENUISTALLED=True
如果结束
下一个
'
如果安装了BLNMenue,则
设置cbcConverterMenu=cbcMenu.Controls(“&Convert-to-QB”)
设置cbcViewConfigMenu=cbcConverterMenu.Controls(“视图配置…”)
'
'步骤1:禁用/启用此菜单的控件
'如果禁用,则禁用除“关于”之外的所有控件
'如果启用,则启用已安装转换器的所有控件
对于cbcConverterMenu.Controls中的每个cbcControl
“保持“关于”处于启用状态
如果cbcControl.Caption“About…”那么
cbcControl.Enabled=blnEnableOptions
如果结束
下一个
'
'步骤2:重建配置文件列表
如果你能选择,那么
'如果Active工作簿目录中存在系统配置文件,请读取它
SC.ConfigFilePath=ActiveWorkbook.Path和Application.PathSeparator
'测试系统配置文件名
SC.SystemConfigFilename=GetConfigFilename(SC,True)
'是否找到系统配置文件?
如果SC.SystemConfigFilename为“”,则
'是,从配置文件获取用户设置
调用GetConfigSettings(SC.ConfigFilePath、SC.SystemConfigFilename)
如果结束
'
'删除现有菜单选项以查看配置文件
对于cbcViewConfigMenu.Controls中的每个cbcControl
cbcControl.Delete
下一个
'添加菜单选项以查看每个配置文件
Dim lCtr为长,strMenuItem为字符串
对于lCtr=1到UBound(文件)
strMenuItem=aryFiles(lCtr)
使用cbcViewConfigMenu
.Controls.Add(类型:=msoControlButton)。标题=strMenuItem
.Controls(strMenuItem).OnAction=“'ThisWorkbook.ViewTextFile”“”和strMenuItem&“””
以
下一个
如果结束
如果结束
Application.ScreenUpdating=True
转到出口处理程序
错误\u处理程序:
MsgBox Err.Number,“SetMenuOptions”,Err.Description,Err.HelpFile,Err.HelpContext
转到出口处理程序
退出\u处理程序:
出口接头
端接头

单击文件>选项>自定义功能区 然后按照以下说明添加或删除或快捷方式:


如果创建了功能区,快捷方式应显示在“自定义功能区”选项卡下。如果所有其他操作都失败,您可以始终将原始快捷方式重新分配给其他操作,同时避免与新的Excel快捷方式分配冲突。

如果外接程序受到保护,则您将无法对其进行太多操作,因为快捷键是通过外接程序设置的。无论如何,试试这个。打开Excel后,在VBA编辑器的即时窗口中键入此
Application.OnKey“^U”,“
现在测试快捷键谢谢,但外接程序(我编写的)没有设置快捷键。它是由Excel单方面分配的。您可以在加载项的
本工作簿的
打开事件中发布代码吗?@SiddharthRout我已经添加了上面的代码。您在
设置菜单选项中有什么?
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