Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

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

This is a fairly easy task if you are on win32. Use Win32 OLE to access it like so

sub getTableDefs { $accessConst = Win32::OLE::Const->Load('Microsoft Access 8.0 O +bject Library'); $daoConst = Win32::OLE::Const->Load('Microsoft DAO 3.51 Object +Library'); #array to hold table names my @names; #Create a new OLE Access.Application object my $app = Win32::OLE->new('Access.Application'); #Open the database being worked in $app->OpenCurrentDatabase($datasource); #Get the database object my $database = $app->CurrentDb(); #Save every table name that is not a system or linked table foreach my $i (0..($database->TableDefs->{Count}-1)) { #If the attributes are 0 (ie a normal table) if(!$database->TableDefs($i)->{Attributes} || $database->Table +Defs($i)->{Attributes} eq $daoConst->{'dbAttachedTable'}) { #add it to the list of valid selections push @names $database->TableDefs($i)->{Name}; } } #Quit the application $app->DoCmd->Quit($accessConst->{'acQuitSaveNone'}); #Return the list of valid table names return @names; }

This is some code I wrote a while ago. It does work but it might not be exactly what you want. It only counts non system tables and non-linked tables. this was in a package.. I moved the constant object declaration into the sub for clarity when I pasted it here.

Again.. this code has been tested and does work. I hope this can be of some use to you.

P.S. If you open up the object browser in access, and you can check what the possible values of the attribute method are, so you can know which table you want to count. There is also a QueryDef collection if you are interested in counting those.


Grygonos

In reply to Re: Flattening Access DB to XML by Grygonos
in thread Flattening Access DB to XML by inman

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 cooling their heels in the Monastery: (None)
    As of 2024-04-25 01:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found