开发者

How do I automate a saved import in a macro in Access 2007?

开发者 https://www.devze.com 2023-03-31 17:45 出处:网络
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:

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:

  1. A "Manage Data Tasks" window pops up.
  2. I have to choose from the following options: Run, Create Outlook Task..., Delete, and Close.
  3. If I select Run, the next pop-up asks, "Overwrite existing table or query?"
  4. I have to cho开发者_JAVA百科ose: Yes or No.
  5. Another window pops up and says, "All objects were imported successfully."
  6. I have to click the OK button.
  7. I have to click the Close 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

0

精彩评论

暂无评论...
验证码 换一张
取 消