MSACCESS - 如何通过 VBA (CommandBarButton) 触发 Excel 的 import/export 向导

MSACCESS - How to trigger the Excel's import/export wizard via VBA (CommandBarButton)

我有一个带有按钮的表单,该按钮必须通过 VBA 触发经典 Excel 的 import/export 向导。

我试图列出所有 CommandBar 以确定我需要的那个,然后是 Excel 的 CommandBarButton,因此我可以将它用于一个功能。我喜欢这个:

Public Function ListCommBars()
Dim cbrBar As CommandBar
'Dim ctlBar As CommandBarButton
'Dim cbrBars As CommandBars
'Dim strVal As String

For Each cbrBar In CommandBars

    Debug.Print cbrBar.Name, cbrBar.NameLocal, cbrBar.visible
Next

End Function

但是这个函数 returns 是我在当前命令栏上无法识别的栏列表.. 我的目标是调用 Excel 的 import/export CommandBarButton 并通过 VBA.

触发它

我该怎么做?

也许你想要:

DoCmd.RunCommand acCmdExportExcel

DoCmd.RunCommand acCmdImportAttachExcel

调用 CommandBars 是不推荐使用的方法。我唯一一次使用它是为了:
CommandBars.ExecuteMso "DataRefreshAll"