Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
perl中的opencurrentdatabase等方法_Perl_Ms Access 2013 - Fatal编程技术网

perl中的opencurrentdatabase等方法

perl中的opencurrentdatabase等方法,perl,ms-access-2013,Perl,Ms Access 2013,我是perl新手。我被要求使用perl在ms access数据库中执行宏。这是我使用的代码 $oAccess = Win32::OLE->GetActiveObject('Access.Application'); $oAccess ->OpenCurrentDatabase($path); $oAccess ->{DoCmd}->RunMacro("DO ALL"); 今天,当我执行程序时,我发现只有当access数据库打开时,代码才能正常工作,否则返回以

我是perl新手。我被要求使用perl在ms access数据库中执行宏。这是我使用的代码

$oAccess = Win32::OLE->GetActiveObject('Access.Application');  
$oAccess ->OpenCurrentDatabase($path);  
$oAccess ->{DoCmd}->RunMacro("DO ALL");  
今天,当我执行程序时,我发现只有当access数据库打开时,代码才能正常工作,否则返回以下错误

Can't call method "OpenCurrentDatabase" on an undefined value at auto.pl line 30  

因此,我想知道,如果没有开放的ms access数据库,我是否可以找到任何其他代码来达到此目的。

我猜这将强制打开access,但我希望程序在不打开access的情况下执行(即只需要一个执行宏的驱动程序)。@Programmer如果你的意思是不希望access可见,那是可行的,否则,您的请求对我来说没有多大意义。是的,我不希望访问权限像我们对
$dbh=DBI->connect(“DBI:ODBC:driver=Microsoft access driver(*.mdb);dbq=xyz.mdb”,$username,$password)所做的那样可见程序员,您需要了解Win32::OLE是如何工作的。这与使用DBI不同。宏从客户端运行。您正在通过Win32::OLE接口自动化Access客户端。我已经更新了示例以隐藏窗口。学习阅读您正在使用的模块的文档
my $MSAccess;
eval {$MSAccess = Win32::OLE->GetActiveObject('Access.Application')};
die "Access not installed" if $@;
unless (defined $MSAccess) {
  $MSAccess = Win32::OLE->new('Access.Application','Quit')
    or die "Unable to start Access";
}
$MSAccess->{visible} = 0;