[EMAIL PROTECTED] <> wrote:
> For those interested I decided to play around with simply finding a
> specific sheet and see what happens if i started with the most basic
> calling by name. the following is my code/errors. On the two times
> that it asked if there was an added sheet, it created a new workbook
> instead and did not create a named sheet.
>
> At least this gives a way to get a sheet already present.
>
> I'm wondering, has anyone started putting together a sheet on OLE or
> OLE/Excel functions and syntaxes? Does anyone know of one?
>
> -Josh
> -----code-----
> #! /usr/bin/perl
> use strict;
> use Win32::OLE qw(in with); # use base OLE use Win32::OLE::Const
> 'Microsoft Excel'; # use OLE/Excel # $Win32::OLE::Warn = 3; # die
> on errors...
>
>
> my $dessheet=shift(@ARGV);
Just shift will do.
> my $fcell='';
> my $workbook='W:/lab reports/tester.xls';
>
> unless(-e $workbook){
> print "cant find the workbook\n";
> }else{
> my $Excel = Win32::OLE -> GetActiveObject('Excel.Application')
> || Win32::OLE -> new('Excel.Application', 'Quit');
> $Excel -> {'Visible'} = 1;
>
> my $report = $Excel->Workbooks->Open("$workbook");
Useless quoting. See 'perldoc -q quoting'
>
> my $ws = $report->Worksheets("$dessheet");
Useless quoting again, but locating a worksheet by name does seem to
work. Colour me mildly surprised.
>
> if($ws){
> $fcell = $ws -> Range("A1") -> {'Value'};
>
> print "\$ws: $ws\n\t\$fcell: $fcell\n";
> }else{
> $workbook = $Excel -> Workbooks -> Add();
This adds a workbook, I thought you wanted to add a worksheet. Shouldn't
that be:
$report->Worksheets->Add;
I don't know that it returns the new worksheet.
> $ws = $workbook -> Worksheets(1);
The added worksheet is made the active worksheet, so that should
probably be
$ws = $report->{ActiveSheet}
> $ws -> { 'Name' } = "new sheet";
> $ws -> Range("A2") -> {'Value'} = "was i successful?";
> print "added sheet?\n";
> }
>
> $Excel -> Workbooks -> Save(); # save file
> $Excel -> Workbooks -> Quit(); # leave excel }
$report->Save();
$Excel->Quit();
HTH
--
Brian Raven
=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the
intended addressee(s). Unauthorised reproduction, disclosure, modification,
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately
and delete it from your system. The views expressed in this message do not
necessarily reflect those of Atos Euronext Market Solutions.
L'information contenue dans cet e-mail est confidentielle et uniquement
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee.
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail
vous parvient par erreur, nous vous prions de bien vouloir prevenir
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre
systeme. Le contenu de ce message electronique ne represente pas necessairement
la position ou le point de vue d'Atos Euronext Market Solutions.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs