gpt4 book ai didi

vba - 删除/列出所有键盘快捷键 VBA excel

转载 作者:行者123 更新时间:2023-12-02 23:15:23 24 4
gpt4 key购买 nike

我们办公室有人为 Ctrl+D 分配了一个宏。这很令人沮丧,因为 Excel 中已经有这个函数了。

Excel 使您可以轻松地在“开发人员”>“宏”中分配宏,而且我知道,如果我按下此菜单中的选项,我可以看到哪些键被分配到了哪里。此工作簿中的宏列表相当大,我不想单独打开每个宏。

这是否已在任何地方列出?我想某处有一个日志?这是我在 msdn 上能找到的最接近的,但我需要在宏工作簿中分配宏:https://msdn.microsoft.com/en-us/library/hh179479(v=nav.90).aspx

最佳答案

感谢@GSerg 指出这一点,我将在此处发布此内容以完整地结束问题。来源在这里:

https://groups.google.com/forum/#!topic/microsoft.public.excel.worksheet.functions/TwcT-IlWjVk

To use this Macro (Sub), <alt-F8> opens the macro dialog box. Select the macro by name, and <RUN>. 
===================================================
Option Explicit
'MUST set to Trust Access to the VBA Project Object Model
' in Excel Options
'Set reference to:
'Microsoft Visual Basic for Applications Extensibility
'Microsoft Scripting Runtime
'Microsoft VBScript Regular Expressions 5.5
Sub ListMacroShortCutKeys()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As CodeModule
Dim LineNum As Long
Dim ProcKind As VBIDE.vbext_ProcKind
Dim sProcName As String, sShortCutKey As String
Const FN As String = "C:\Temp\Temp.txt"
Dim S As String
Dim FSO As FileSystemObject
Dim TS As TextStream
Dim RE As RegExp, MC As MatchCollection, M As Match

Set RE = New RegExp
With RE
.Global = True
.IgnoreCase = True
.Pattern = "Attribute\s+(\w+)\.VB_ProcData\.VB_Invoke_Func = ""(\S+)(?=\\)"
End With

Set FSO = New FileSystemObject
Set VBProj = ActiveWorkbook.VBProject
For Each VBComp In VBProj.VBComponents
Select Case VBComp.Type
Case Is = vbext_ct_StdModule
VBComp.Export FN
Set TS = FSO.OpenTextFile(FN, ForReading, Format:=TristateFalse)
S = TS.ReadAll
TS.Close
FSO.DeleteFile (FN)
If RE.Test(S) = True Then
Set MC = RE.Execute(S)
For Each M In MC
Debug.Print VBComp.name, M.SubMatches(0), M.SubMatches(1)
Next M
End If
End Select
Next VBComp
End Sub
==============================

关于vba - 删除/列出所有键盘快捷键 VBA excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39534606/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com