简体   繁体   中英

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

I have a form with a button that HAS to trigger the classic Excel's import/export wizard via VBA.

在此处输入图片说明

I tried to list all the CommandBar in order to identify the one i need and next the Excel's CommandBarButton , so i can use it for a function. i did like this:

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

but this function returns a list of bars i can't recognize on my current commandbars.. my goal is to call the Excel's import/export CommandBarButton and trigger it via VBA.

How can i do that?

Maybe you want:

DoCmd.RunCommand acCmdExportExcel

or

DoCmd.RunCommand acCmdImportAttachExcel

Calling CommandBars is deprecated method. Only time I've ever used it is for:
CommandBars.ExecuteMso "DataRefreshAll"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM