I am getting an error with OLE on trying to open a file and create it. do
these have to be done separately? if so, what is the correct way? I don't
have the luxury of a machine I can be detrimental to while experimenting.
the following is the header of my code, where I try to open the file and
create it, along with the first row and closing.
TIA for your time,
-Josh
-- code---
#! /usr/bin/perl
use strict;
use warnings;
use Getopt::Long; # used in getting unix-style options
use Win32::OLE::Const 'Microsoft Excel'; # use OLE/Excel
$Win32::OLE::Warn = 3; # die on errors...
# a lot of working code removed for brevity
# get the date
my @rdate=split ' ', localtime();
$date=$rdate[4].'-'.$rdate[1].'-'.$rdate[2];
if($verb>1){ &rep("$date\n",$verb); }
# a lot of working code removed for brevity
#######
## OLE interaction upon the saved files follows
#######
# get active Excel
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit');
$Excel -> {'Visible'} = 1;
# open the excel
my $report = $Excel->Workbooks->Open("Lab_Report_$date.xls");
# set worksheet
my $ws = $report->Worksheets(1);
# 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";
my $ldate = localtime();
&rep("Examining information gathered from lab computers @ $ldate\n",
$verb);
# start row counter
my $row=2;
foreach my $node (@comps){
# a lot of loops removed for brevity
}
$Excel->Workbooks-> Save();
$Excel->Workbooks-> Quit();
my $et=locatime();
&rep("program completed at $et.",$verb);
close LOG;
-----------------------------------------
PLEASE NOTE:
SeaChange International headquarters in Maynard, MA is moving!
Effective March 1, 2006, our new headquarters address will be:
SeaChange International
50 Nagog Park
Acton, MA 01720 USA
All telephone numbers remain the same:
Main Corporate Telephone: 978-897-0100
Customer Service Telephone: 978-897-7300
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs