The documentation of Workbooks.Open says:
By default, macros are enabled when opening files programmatically. Use the AutomationSecurity property to set the macro security mode used when opening files programmatically.
This works for me:
use warnings; use strict; use Win32::OLE (); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; # die on errors my $Excel = Win32::OLE->new('Excel.Application', 'Quit') or die "Faile +d to open Excel"; # or to get running Excel instance: Win32::OLE->GetActiveObject('Excel +.Application') my $const = Win32::OLE::Const->Load('Microsoft Office '.$Excel->{Versi +on}.' Object Library'); $Excel->{AutomationSecurity} = $const->{msoAutomationSecurityForceDisa +ble}; $Excel->{Visible} = 1; my $Book = $Excel->Workbooks->Open("filename.xlsm"); $Book->Activate; # ... $Excel->Quit;
In reply to Re: Win::OLE Excel: disable macros
by haukex
in thread Win::OLE Excel: disable macros
by Ratazong
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |