快速访问工具栏会在VBA中使用插件时重置自身

时间:2019-09-12 11:07:12

标签: excel vba

因此,我创建了此 Addin ,以使人们更轻松地使用Macros。

  • 加载项Workbook_Open事件中使用以下代码创建快捷方式。

代码:

Private Sub Workbook_Open()

Dim hFile As Long
Dim path As String, fileName As String, ribbonXML As String, user As String

hFile = FreeFile
user = Environ("Username")
path = "C:\Users\" & user & "\AppData\Local\Microsoft\Office\"
fileName = "Excel.officeUI"

ribbonXML = "<mso:customUI      xmlns:mso='http://schemas.microsoft.com/office/2009/07/customui'>" & vbNewLine
ribbonXML = ribbonXML + "  <mso:ribbon>" & vbNewLine
ribbonXML = ribbonXML + "    <mso:qat/>" & vbNewLine
ribbonXML = ribbonXML + "    <mso:tabs>" & vbNewLine
ribbonXML = ribbonXML + "      <mso:tab id='reportTab' label='Macros-MB' insertBeforeQ='mso:TabFormat'>" & vbNewLine
ribbonXML = ribbonXML + "        <mso:group id='reportGroup' label='Macros-MB' autoScale='true'>" & vbNewLine
ribbonXML = ribbonXML + "          <mso:button id='automation1' label='Text_Save' " & vbNewLine
ribbonXML = ribbonXML + "imageMso='FileSave'      onAction='testingmacro'/>" & vbNewLine
ribbonXML = ribbonXML + "        </mso:group>" & vbNewLine
ribbonXML = ribbonXML + "      </mso:tab>" & vbNewLine
ribbonXML = ribbonXML + "    </mso:tabs>" & vbNewLine
ribbonXML = ribbonXML + "  </mso:ribbon>" & vbNewLine
ribbonXML = ribbonXML + "</mso:customUI>"

ribbonXML = Replace(ribbonXML, """", "")

Open path & fileName For Output Access Write As hFile
Print #hFile, ribbonXML
Close hFile

End Sub

问题在于,如果有人使用此 Addin ,它将重置快速访问工具栏,而快速访问中的所有快捷方式都消失了。


如果我们打开工作簿,则不使用Addin,就存在快捷方式。

aghsdg


使用插件后

enter image description here

我无法在代码中找到导致“快速访问”工具栏重设自身的任何内容。任何帮助表示赞赏

0 个答案:

没有答案