sub activeDatabase { #get the present working directory $pwd = `cd`; #remove its \n chomp $pwd; return ($pwd . "\\xxx.mdb"); } #### ##Prints a report## sub printReport { my $source = shift; my $report_name = shift; #Make an Access.Application object my $app = Win32::OLE->new('Access.Application') or die "Failed to print report!"; #Open the database $app->OpenCurrentDatabase($datasource); #Make it Invisible $app->{Visible} = 0; #Open the report in design mode $app->DoCmd->OpenReport($report_name,$accessConst->{'acViewDesign'}); #Change the reports RecordSource property $app->Reports->Item($report_name)->{RecordSource} = $source; #Save the report $app->DoCmd->Save($accessConst->{'acReport'},$report_name); #Close the report $app->DoCmd->Close($accessConst->{'acReport'},$report_name); #Print the report $app->DoCmd->OpenReport($report_name); #Quit the application $app->DoCmd->Quit($accessConst->{'acQuitSaveNone'}); }