Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel, install perl script 2apart Excel Discussion (Misc queries) 0 March 26th 08 11:28 PM
minor but irritating problem when generating Excel files with Perl EJF Excel Programming 5 March 7th 06 06:06 AM
code sample for executing a VB function in Excel using perl newOLE Excel Worksheet Functions 7 August 10th 05 10:26 PM
excel, vb arrays and perl Mark Seger Excel Programming 0 June 4th 05 01:11 PM
Excel 2000 Macro and Perl problem Jim Simpson Excel Programming 0 May 19th 04 06:45 PM


All times are GMT +1. The time now is 02:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"