Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel in Perl VIA OLE -- saving workbook(s)
in the following code, line 232 (the save line that is called after the loop)
errors and kills the program. this is causing another error later on when i call this again. Does anyone know why this is or have suggestions on how to fix it? if(-e "$labrep"){ #we are just adding to it, so open it my $report = $Excel-Workbooks-Open("$labrep"); # my $ws = $report-Worksheets("$date - General"); my $ws = $report-Worksheets(1); # start row counter my $row=2; # set row counter to continue at the end of what's there my $ncell = $ws - Range("A$row") - {'Value'}; while($ncell =~ m/\w+/i){ $row++; # increment row & V- grab next row's data -V $ncell = $ws - Range("A$row") - {'Value'}; } # we need to get the information & parse it into the excel file for each node foreach my $node (@comps){ # for each node we check the information returned my $ldate = localtime(); &rep("Examining information gathered from node $node @ $ldate\n", $verb); # a sub routine defined later in the script is used for simplicity &populate($node,$row,$ws); # end the loop increasing the row number $row++; } }else{ # we have to create it, including make the first row $Excel - { 'SheetsInNewWorkBook' } = 1; my $workbook = $Excel - Workbooks - Add(); my $ws = $workbook - Worksheets(1); $ws - { 'Name' } = "$date - General"; # set first row titles $ws - Cells(1, "A") - {'Value'} = "Node"; $ws - Cells(1, "B") - {'Value'} = "NAV"; $ws - Cells(1, "C") - {'Value'} = "Alarms"; $ws - Cells(1, "D") - {'Value'} = "SNMP"; $ws - Cells(1, "E") - {'Value'} = "Uptime"; $ws - Cells(1, "F") - {'Value'} = "Kernel Version"; $ws - Cells(1, "G") - {'Value'} = "Product Type"; $ws - Cells(1, "H") - {'Value'} = "Product Version"; $ws - Cells(1, "I") - {'Value'} = "Service Pack"; $ws - Cells(1, "J") - {'Value'} = "Kernel Build Number"; $ws - Cells(1, "K") - {'Value'} = "Registered Organization"; $ws - Cells(1, "L") - {'Value'} = "Registered Owner"; $ws - Cells(1, "M") - {'Value'} = "Install Date"; $ws - Cells(1, "N") - {'Value'} = "Activation Status"; $ws - Cells(1, "O") - {'Value'} = "IE Version"; $ws - Cells(1, "P") - {'Value'} = "System Root"; $ws - Cells(1, "Q") - {'Value'} = "Processors"; $ws - Cells(1, "R") - {'Value'} = "Processor Speed"; $ws - Cells(1, "S") - {'Value'} = "Processor Type"; $ws - Cells(1, "T") - {'Value'} = "Physical Memory"; $ws - Cells(1, "U") - {'Value'} = "Installed OS Hotfixes"; $ws - Cells(1, "V") - {'Value'} = "Other Applications"; $ws - Columns("A:V") - AutoFit(); # start row counter my $row=2; foreach my $node (@comps){ # for each node we check the information returned my $ldate = localtime(); &rep("Examining information gathered from node $node @ $ldate\n", $verb); # a sub routine defined later in the script is used for simplicity &populate($node,$row,$ws); # end the loop increasing the row number $row++; } $workbook - SaveAs($labrep); # save active sheet } # save and exit $Excel - Workbooks - Save(); # save file $Excel - Workbooks - Quit(); # leave excel my $et=locatime(); &rep("program completed at $et.",$verb); # wrap up log close LOG; # close log |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel, install perl script | Excel Discussion (Misc queries) | |||
minor but irritating problem when generating Excel files with Perl | Excel Programming | |||
code sample for executing a VB function in Excel using perl | Excel Worksheet Functions | |||
excel, vb arrays and perl | Excel Programming | |||
Excel 2000 Macro and Perl problem | Excel Programming |