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

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,

Replies are listed 'Best First'.
Re^3: Use Win32::OLE to run vba subroutine in MS Access
by NetWallah (Canon) on Oct 07, 2008 at 05:28 UTC
    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