#!perl -w
#-- code to access Ms Access objects
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft DAO';
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
my $file = q{C:\\...\\Northwind 2007.accdb};
my $appAcc = Win32::OLE->new('Access.Application', 'Quit');
my $Workspace = $appAcc->DBEngine->CreateWorkspace('', 'Admin', '');
# $appAcc->OpenCurrentDatabase
my $Database = $Workspace->OpenDatabase($file);
# my $Database = $appAcc->OpenCurrentDatabase($file);
if (!$Database) {
print Win32::OLE->LastError(), "\n";
} else {
print $Database->{Name}, "\n";
print $Database->{CurrentProject}->Modules(0)->{Name}, "\n";
}
The last statement causes the error:
OLE exception from "DAO.TableDefs":
Item not found in this collection.
Win32::OLE(0.1709) error 0x80020009: "Exception occurred"
in METHOD/PROPERTYGET "CurrentProject" at getAccessOLE.pl line 27
|