in reply to Exporting VBA code from Excel: Win32::OLE exceptions & orphaned processes

ISSUE 1:

And off to search MSDN you go :) Programmatic access to Office VBA project is denied, Programmatic access to Visual Basic Project is not trusted

ISSUE 2: When the program errors, there is no chance to kill the Excel process just created.

eval or OLE die handler or both?

my $excel = MakeItStart(); eval { DoStuff( $excel ); 1; } or do { warn "UHOH $@ "; KillIt( $excel ); }; exit( 0 );
  • Comment on Re: Exporting VBA code from Excel: Win32::OLE exceptions & orphaned processes
  • Download Code

Replies are listed 'Best First'.
Re^2: Exporting VBA code from Excel: Win32::OLE exceptions & orphaned processes
by shockers_jm (Initiate) on Apr 01, 2015 at 23:29 UTC
    Thank you, thank you, thank you Anonymous!

    Issue 1 resolved, for Excel 2007 on Win7:

    File
    -> Options
    -> Trust Center
    -> Trust Center Settings
    -> Macro Settings
    -> (x) Trust access to the VBA project object model

    I'm sure it's something similar for XP.

    For Issue 2, eval() huh? Interesting.

    The $excel should be

    $xl_obj = Win32::OLE->new('Excel.Application');
    
    and most everthing else is the DoStuff to be eval'd.

    I'll play around with that.

    I still have the brute-force before/after process list trick to fall back on.

    Mucho thanks.