Running Menu Commands from VBA

Colt45

Registered User.
Local time
Today, 22:39
Joined
Jul 21, 2010
Messages
13
Hi all,
this is my first question on these forums, so please forgive any unintentional bloopers or faux pas!

I have a database which is really simple - it's actually only a linked table. I use it to change the format of a text field which contains a date. All I do in the database is select the linked table, and export it as a fixed width file under a new name using the export wizard. The link specification takes care of the format change. Dead easy!

Now, some other users need to do this, and they are not familiar with Access, so I'd like to automate the export. I have an example which comapcts the database, and works fine, but when I tried that approach on the export, I find it defaults to exporting the Module the function is written in.

So my question is, how do I tell VBA which object I want to export? (In this case a table)

Here is the code I have so far:

Option Compare Database
Option Explicit

Public Function ExportForecast()

CommandBars("Menu Bar"). _
Controls("File"). _
Controls("Export..."). _
accDoDefaultAction

End Function

I've tried different ways to find help on this, but the stuff I could find was mostly about creating new custom menus, not simply how to run pre-defined commands from inside VBA.

Thanks in advance!
 
Thank you sir!

I looked it up, tried it and hit runtime error 3027, but someone else had already answered that on this site (Google brought me right back here!).

Thanks, this is really cool!

Cheers,
Colt45
 

Users who are viewing this thread

Back
Top Bottom