无法从perl运行power point宏

无法从perl运行power point宏,perl,vba,powerpoint,Perl,Vba,Powerpoint,我有一个用powerpoint编写的宏,我需要从perl脚本调用它,可以使用$Excel->Run(“MyMacroname here”)从Excel调用宏但在powerpoint中使用“运行”,会出现以下错误: “Microsoft PowerPoint 2010”中的OLE异常: Application.Run:请求无效。未定义子或函数。 Win32::OLE(0.1709)方法/PROPERTYGET“Run”中出现错误0x80048240 下面是我用来从powerpoint调用宏的per

我有一个用powerpoint编写的宏,我需要从perl脚本调用它,可以使用$Excel->Run(“MyMacroname here”)从Excel调用宏但在powerpoint中使用“运行”,会出现以下错误:

“Microsoft PowerPoint 2010”中的OLE异常: Application.Run:请求无效。未定义子或函数。 Win32::OLE(0.1709)方法/PROPERTYGET“Run”中出现错误0x80048240

下面是我用来从powerpoint调用宏的perl:

my $filename = "<path>";
my $PptApp  = Win32::OLE->GetActiveObject('PowerPoint.Application')|| Win32::OLE->new('PowerPoint.Application', 'Quit'); 
$PptApp->{Visible} = 1;
my $Presentation = $PptApp->Presentations->Open({FileName=>"$filename",ReadOnly=>0});
$PptApp->Run("macro_name");
my$filename=”“;
我的$PptApp=Win32::OLE->GetActiveObject('PowerPoint.Application')| | Win32::OLE->new('PowerPoint.Application','Quit');
$PptApp->{Visible}=1;
我的$Presentation=$PptApp->Presentations->Open({FileName=>“$FileName”,ReadOnly=>0});
$PptApp->Run(“宏名称”);

您正在使用power point应用程序对象运行Excel宏。那是行不通的。您需要获取Excel实例并使用其应用程序对象来运行Excel宏。或者,您可以将VBA代码复制到PowerPoint模块中

宏必须被定义,而且我很确定,必须声明为Public

并且,从MSDN():

要运行的过程的名称。该字符串可以包含以下内容:加载的演示文稿或加载项文件名,后跟感叹号(!),有效模块名,后跟句点(.),以及过程名。例如,下面是一个有效的宏名值:“MyPres.ppt!Module1.Test。”



但是,如果该过程声明为Public,并且是加载的加载项的一部分,则只需提供过程名称。

您的代码是正确的。是否确实定义了具有给定名称的宏?