in reply to Re^2: Creating Excel Macros from Perl
in thread Creating Excel Macros from Perl
Try changing "vbextFileTypeModule" to 1 or find the correct constant, possibly vbext_ct_StdModule.
You'll need to set your macro security settings to low and probably trust access to the project as well.
Update:
This works on Excel 2003 after setting macro security settings to low and trusting access to the project:use strict; use warnings; use Win32::OLE; use Win32::OLE::Const "Microsoft Excel"; use Win32::OLE::Const "Microsoft Visual Basic for Applications Extensi +bility"; my $xls = Win32::OLE->new('Excel.Application'); $xls->{Visible} = -1; my $wb = $xls->Workbooks->Add; my $mod = $wb->VBProject->VBComponents->Add(1); $mod->{Name}="NewMod"; $mod->CodeModule->AddFromString ( <<MODTEXT); Sub Message dim s as string s = "Hello, World" MsgBox s End Sub MODTEXT my $sheet = $xls->Sheets('Sheet1'); my $button = $sheet->Buttons->Add(71.25, 18.75, 88.5, 57); $button->{OnAction} = 'Message';
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Creating Excel Macros from Perl
by ChumpChief (Initiate) on Jul 30, 2008 at 20:10 UTC | |
Re^4: Creating Excel Macros from Perl
by Anonymous Monk on Jan 08, 2014 at 12:38 UTC | |
by Corion (Patriarch) on Jan 08, 2014 at 12:41 UTC | |
by Anonymous Monk on Jan 08, 2014 at 12:47 UTC |
In Section
Seekers of Perl Wisdom