in reply to Use Win32::OLE to run vba subroutine in MS Access

If all you need to do is run an Access macro, perl may not be the most expedient/appropriate solution. Here is an alternative:
msaccess.exe "c:\My Documents\Databases\MyDatabase.mdb" /x MyMacro

     Have you been high today? I see the nuns are gay! My brother yelled to me...I love you inside Ed - Benny Lava, by Buffalax

Replies are listed 'Best First'.
Re^2: Use Win32::OLE to run vba subroutine in MS Access
by bdbmeag (Initiate) on Oct 06, 2008 at 21:01 UTC
    Hi, Where do you run this line of code (msaccess.exe "c:\My Documents\Databases\MyDatabase.mdb" /x MyMacro)? .......................................... Here is update on where I am ... The error message I get is "Couldn't open database s:/mdbtest! at s:\mdbtest.pl line 20.
    #!/usr/bin/perl use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Access'; Win32::OLE->Option(Warn => 0); my $oAccess; my $oDatabase; my $filename = "s:/mdbtest.mdb"; # $ARGV[0]; print $filename."\n"; $oAccess = Win32::OLE->new('Access.Application') or die qq{Couldn't st +art new Access instance!}; # Open Access File $oDatabase = $oAccess->DBEngine->OpenDatabase($filename) or die qq{Cou +ldn't open database $filename!}; $oDatabase->Run("RunTest"); print "$filename"."\n"; $oDatabase->Save; undef $oDatabase; undef $oAccess; $oAccess->Quit();
    Thanks,
      I was suggesting you abandon your entire program, and run the following instead, either as a bat file, or directly from the command prompt:
      msaccess.exe s:\mdbtest.mdb /x RunTest
      In case you want to pursue the perl route, please add an error message display to your code. This will make it easier to identify the problem:
      # Open Access File $oDatabase = $oAccess->DBEngine->OpenDatabase($filename) or die qq{Couldn't open database $filename!\n} . Win32::OLE->LastError();

           Have you been high today? I see the nuns are gay! My brother yelled to me...I love you inside Ed - Benny Lava, by Buffalax