in reply to Win::OLE Excel: disable macros
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Win::OLE Excel: disable macros
by Ratazong (Monsignor) on Feb 16, 2022 at 12:25 UTC |