|
我将你的模块1改名为modRibbon
修改其内容为
- Public Function LoadRibbon() As Boolean
- ' 从 xml 文件加载功能区
- On Error GoTo Err_LoadRibbon
- Dim fn As Long
- Dim strText As String
- Dim strOut As String
-
- fn = FreeFile ' 获取一个文件号
-
- ' 打开当前工程文件夹中 AccRibbon.xml 文件
- ' 该文件中存储功能区的 xml 代码
- Open CurrentProject.Path & "\AccRibbon.xml" For Input As fn
-
- ' 按行读取并连接起来保存到 strOut 变量
- Do While Not EOF(fn)
- Line Input #fn, strText
- strOut = strOut & strText
- Loop
- Close fn ' 关闭文件
- ' 加载功能区,其名称为 "Main"
- Application.LoadCustomUI "Main", strOut
- LoadRibbon = True
- LoadRibbon_Exit:
-
- Exit Function
- Err_LoadRibbon:
- Select Case Err.Number
- Case 32609
- ' Ribbon already loaded
- Debug.Print "功能区已经加载"
- Case Else
- MsgBox "Error: " & Err.Number & vbCrLf & _
- Err.Description, vbCritical, _
- "Error", Err.HelpFile, Err.HelpContext
- End Select
- Err.Clear
-
- GoTo LoadRibbon_Exit
- End Function
复制代码 |
|