data from Acces to Excel

Bill Bell bill-bell at bill-bell.hamilton.on.ca
Sat Jun 30 19:06:58 EDT 2001


"baton" <batonn at poczta.fm> wrote, in part:
> I wonder if there is a possibilyty to export table from Access
> database to Excel using python language?? If yes, could you tell me
> how to do it or where I can find info how to do it?

Yes, it's possible and not too difficult.

1. Launch MS Excel.

2. Create a query against the Access database (Data | Get 
external data | Create new query).

3. Start saving a macro.

4. Import the data using the query you have just created (Data | 
Get external data | Run database query). 

5. Stop saving the macro.

6. Open the macro in the Visual Basic editor (Tools | Macro | 
Macros) and translate it to Python, using techniques described in 
Chapter 12 of Hammond and Robinson, Python Programming on 
Win32, O'Reilly (this chapter is available on www.oreilly.com).

That's it! If you need to import different data from MS Access then 
make your Python script construct the query for itself rather than 
using MS Excel to do it in the way mentioned above.

Good luck.

Bill




More information about the Python-list mailing list