At 08:58 AM 9/7/2005, Arun Tyagi wrote:
>Hi Bob,
>
>last time i asked u how to run access macro through
>python? and ur solution worked fine, so thanks a lot fot it.

You are welcome. And please in the future give a meaningful subject on your 
questions. it helps us track the questions. Also please reply to the list 
as well as to me, since another might jump in with the next answer, and we 
all learn by following these threads.

>Now i got another problem.

Don't we all.

>I want to know how can we export/import text file in Access using python?

All Office applications use VBA as the core of their macro language, along 
with application-specific extensions to VBA. You may invoke any of these 
operations the same way you used RUN in my previous answer.

There are several ways to discover the relevant commands.

1 - Open Access, then open the Visual Basic Editor under Tools->Macros..., 
press F2 to get the object browser, then Find to narrow the search to the 
operation you want. The syntax is displayed at the bottom of the browser. 
Press F1 to get the help details.

2 - Record a macro then do the Access thing to import a text file. Then 
Edit the macro. Then copy the relevant commands to your Python program, or 
run the macro itself from Python.

3 - Get a copy of Python Programming on Win32 (Hammond & Robinson) O'Reilly 
Press. Will explain a lot. Pay attention to makepy which can make like 
easier and things go faster.

What you want in this situation is TransferText. This is an access action; 
to invoke it as a method requires DoCmd (as the help file will show you).

Syntax: TransferText([TransferType As AcTextTransferType = acImportDelim], 
[SpecificationName], [TableName], [FileName], [HasFieldNames], 
[HTMLTableName], [CodePage])

You will have to lookup the TextTransferType to get the numeric value for 
this parameter, and of course there may be other things to establish (such 
as a specification) that is access specific and not a topic for Python.

So the Python side begins to look like:
a.DoCmd.TransferText(transfertype, specname or None, tablename, filename)

I hope this steers you to your answer and helps you see how to find further 
answers on your own. We on this list like to help and helping you help 
yourself gives us more time for our own work. Of course some of us are also 
available to take on larger assignments as consultants. 

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to