Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Warning: This is completely untested. I don't have MS Access, and I never use Win32:OLE, but at least I know what it is.

I found the VBA script (emdeded in POD in the program below), to do this here, and I've made an attempt to convert is to Perl/OLE to give you a starting point. (But don't ask me questions cos I won't know the answers. Well, you can try, but you've been warned:)

use strict; use warnings; use Win32::OLE; =VBA Dim accessApp as Access.Application Dim strDB as string Dim strImport as string set accessApp = new Access.Application strDB = "C:\Test\MyDatabase.mdb" strImport = "R:\Download\ImportFile.txt" accessApp.OpenCurrentDatabase strDB accessApp.DoCmd.TransferText acImportDelim, , "TableX", strImport, -1 accessApp.CloseCurrentDatabase =cut ## connect to Access my $access = Win32::OLE->new 'Access.Application' ) or die "Cannot create Access object:$!\n"; ## connect to the database $access->OpenCurrentDatabase( 'x:\The\path\to\your\database.mdb'); ## run the import command $access->DoCmd->TransferText( ',', ## The delimiter 0, ## First line contains field names. (1 if yes) 'YourTableName', ## The name of the table to import to 'x:/the/path/to/the/file.csv', ## file to import -1 ########### Haven't a clue what this is, ## but you should be able to work it out by looking at the ## Text Transfer menu ) or die $^E; ## and done $access->Quit();

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: accessing MS Access databases by BrowserUk
in thread accessing MS Access databases by memo.garciasir

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-19 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found