I have created a macro to run a saved import (a file imported from Excel into Access 2007). When I run the macro, the saved import runs and the following happens:
- A "Manage Data Tasks" window pops up.
- I have to choose from the following options:
Run
,Create Outlook Task...
,Delete
, andClose
. - If I select
Run
, the next pop-up asks, "Overwrite existing table or query?" - I have to cho开发者_JAVA百科ose:
Yes
orNo
. - Another window pops up and says, "All objects were imported successfully."
- I have to click the
OK
button. - I have to click the
Clos
e button on the "Manage Data Tasks" Window.
Is there any way that I can automate all these button clicks if they are always going to be the same? (The bold faced buttons are the ones that I'll always be clicking.)
If you use the DoCmd.RunSavedImportExport Method you won't have to interact with the Manage Data Tasks dialog at all.
DoCmd.RunSavedImportExport "YourSavedImportName"
You will however have to deal with the possible errors that get raised. For example if your source file is unavailable you will get an error like
Run-time error '3011':
The Microsoft Office Access database engine could not find the object 'Sheet1'. Make sure the object exists and the you spell its name and the path correctly.
This may be too simple, but can you use the Setwarnings:off command in your macro before you import.
Now I would like to see the macro to automate the import
精彩评论