Ideally, what I want is to a have a perl script invoke the Win32::OLE macro 'Run' function in newly generated *.csv files that reference predefined macros residing in a Personal.xls file under D:\Profiles\P56739\Application Data\Microsoft\Excel\XLSTART. Manually, I can open a newly generated *.csv on my desktop, go to 'Tools', go to 'Macros', visibly see Personal.xls!SLOC_Count_C_Sharp_Macro in the Macro name box, highlight the name, and 'Run' the macro, which executes correctly every time. But for the like of me, I cannot get Win32::OLE via the 'Run' method to do the same thing. What's going here??? I would appreciate any insight to this silly problem. Thanks. BG-------------------------------------------- OLE exception from "Microsoft Office Excel" 'SLOC_Count_C_Sharp_Macro' could not be found. Check the spelling of the file name, and verify the file location is correct. Win32::OLE<0.1707> error 0x800a03ec in METHOD/PROPERTYGET "Run" at test.txt line 27 -------------------------------------------- <<< Code Snippet >>> use Cwd; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; ##my $myPersonalMacros = "D:\\Profiles\\P56739\\Application Data\\Micr +osoft\\Excel\\XLSTART\\Personal.xls"; my $metricsFile = "D:\\Profiles\\P65380\\Deskto\\myMetricsFile.csv"; my $Excel = Win32::OLE->new('Excel.Application') or die "\n\nOops, can +not start Excel\n";; my $Book = $Excel->Workbooks->Open("$metricsFile"); my $Sheet = $Book->Worksheets(1); $Sheet->Activate(); $Excel->Run("Personal.xls!SLOC_Count_C_Sharp_Macro"); $Book->Close; I have everything under the sun to get this to work! It makes no difference; same error returns. I.E. $Excel->Run("SLOC_Count_C_Sharp_Macro"); $Excel->Run("Personal.xls!SLOC_Count_C_Sharp_Macro"); Even... $Excel->Run("$myPersonalMacros!SLOC_Count_C_Sharp_Macro");
Code tags added by GrandFather
In reply to Re: Using Win32::OLE and Excel - Tips and Tricks by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |