RE: Excel, OLE, and Activestae PERL 5.6.1 rel 633 on Windows 2K.

2002-10-30 Thread Charbeneau, Chuck
> From: Daniel Needles [mailto:daniel.needles@;Callisma.com] 
> Subject: Excel, OLE, and Activate PERL 5.6.1 rel 633 on Windows 2K.

> The following program:
[SNIP]
> 
> C:\Documents and Settings\dln1\AANC>perl test.pl
> 
>   Win32::OLE(0.1502) error 0x80070005: "Access is denied" in 
> PROPERTYPUT "Visible" at test.pl line 6
>   Win32::OLE(0.1502) error 0x80070005: "Access is denied" in 
> METHOD/PROPERTYGET "" at test.pl line 7
>   Can't call method "Open" on an undefined value at test.pl line 7.


I'll ask the same questions I asked on Perl Monks to this:

Do you have Excel Installed on this Machine?
What happens when you put error checking in?


use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3; # Die on Errors.

my $excelfile = 'book1.xls';

my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit')
|| die Win32::OLE->LastError(); 

   $Excel->{DisplayAlerts}=0;   

my $Book = $Excel->Workbooks->Open($excelfile) or die
Win32::OLE->LastError();

print Win32::OLE->LastError();


Chuck Charbeneau
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Excel, OLE, and Activestae PERL 5.6.1 rel 633 on Windows 2K.

2002-10-30 Thread Daniel Needles
Chuck,
  Thanks for the response. Sorry about that. I sent the message out
before checking monks again.

1. I have MS Excel 2000 9.0.3821 SR-1.

2. The program was:

use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3; # Die on Errors.

my $excelfile = 'C:\tmp\Book1.xls';

# VERIFY EXISTENCE
print "LISTING $excelfile\n";
print `dir $excelfile`;

my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit')
|| die Win32::OLE->LastError();

   $Excel->{DisplayAlerts}=0;

my $Book = $Excel->Workbooks->Open($excelfile) or die
Win32::OLE->LastError();

print Win32::OLE->LastError();

The results  were:

C:\Documents and Settings\dln1\My Documents\White Papers\AANC>perl
test2.pl
LISTING C:\tmp\Book1.xls
 Volume in drive C is LOCAL DISK
 Volume Serial Number is 9C3D-51DA

 Directory of C:\tmp

10/30/2002  10:17a  13,824 Book1.xls
   1 File(s) 13,824 bytes
   0 Dir(s)   8,264,424,960 bytes free
Win32::OLE(0.1502) error 0x80070005: "Access is denied"
in PROPERTYPUT "DisplayAlerts" at test2.pl line 17

C:\Documents and Settings\dln1\My Documents\White Papers\AANC>


Thanks,
Daniel

-Original Message-
From: Charbeneau, Chuck [mailto:CCharbeneau@;lear.com]
Sent: Wednesday, October 30, 2002 12:14 PM
To: '[EMAIL PROTECTED]';
[EMAIL PROTECTED]
Subject: RE: Excel, OLE, and Activestae PERL 5.6.1 rel 633 on Windows
2K.


> From: Daniel Needles [mailto:daniel.needles@;Callisma.com]
> Subject: Excel, OLE, and Activate PERL 5.6.1 rel 633 on Windows 2K.

> The following program:
[SNIP]
>
> C:\Documents and Settings\dln1\AANC>perl test.pl
>
>   Win32::OLE(0.1502) error 0x80070005: "Access is denied" in
> PROPERTYPUT "Visible" at test.pl line 6
>   Win32::OLE(0.1502) error 0x80070005: "Access is denied" in
> METHOD/PROPERTYGET "" at test.pl line 7
>   Can't call method "Open" on an undefined value at test.pl line 7.


I'll ask the same questions I asked on Perl Monks to this:

Do you have Excel Installed on this Machine?
What happens when you put error checking in?


use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3; # Die on Errors.

my $excelfile = 'book1.xls';

my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit')
|| die Win32::OLE->LastError();

   $Excel->{DisplayAlerts}=0;

my $Book = $Excel->Workbooks->Open($excelfile) or die
Win32::OLE->LastError();

print Win32::OLE->LastError();


Chuck Charbeneau

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Excel, OLE, and Activestae PERL 5.6.1 rel 633 on Windows 2K.

2002-10-31 Thread Daniel Needles
Chuck,
  Thanks for all the help. I found the problem. This one is rather
embarrassing, but interesting so I thought I'd let the group in on it.

  I was racking my brain thinking what the hell could enforce
permissions out side the standard Win2K user stuff. Then I remembered.
A while back I installed Network Associates VirusScan Console software
in order to be able to connect from the outside into my client site. I
shut it off and reran the test. Worked like a charm.

Thanks,
Daniel

-Original Message-
From: Charbeneau, Chuck [mailto:CCharbeneau@;lear.com]
Sent: Thursday, October 31, 2002 4:35 AM
To: '[EMAIL PROTECTED]'
Subject: RE: Excel, OLE, and Activestae PERL 5.6.1 rel 633 on Windows
2K.


> From: Daniel Needles [mailto:daniel.needles@;Callisma.com]
> Subject: RE: Excel, OLE, and Activestae PERL 5.6.1 rel 633 on
> Windows 2K.

>$Excel->{DisplayAlerts}=0;

> Win32::OLE(0.1502) error 0x80070005: "Access is denied"
> in PROPERTYPUT "DisplayAlerts" at test2.pl line 17


I have a feeling that if you loose this line, the next time you try to
set a
property, you are going to get the same error.

All this does is tell Excel not to throw any pop-up dialogs, and if it
needs
input, take the default (which is usually the safest choice).  You can
try
and remove this line (especially if you leave the Add line the way it
is).

The only other things that I can think of is using Variant true and
false
instead of 1 and 0, and/or setting Visible to true.  I run each code
snippet
on my machine before I send it, so I know it works, so I'm truly
puzzled as
to why yours isn't working.

Somehow, I think it's a permissions issue. Does the user that's
creating the
file have access to run things as admin or system?  If login as an
admin,
what happens?

Chuck.

-Original Message-
Chuck,
  I made the switch with the same error. I also recreated the Excel
file using the same user by going into Excel, save as, and quit. Then
from a cmd prompt I called the script file and got the same error.

The new code reads:

C:\Documents and Settings\dln1\My Documents\White Papers\AANC>type
test2.pl
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3; # Die on Errors.

my $excelfile = 'C:\tmp\Book1.xls';

# VERIFY EXISTENCE
print "LISTING $excelfile\n";
print `dir $excelfile`;

my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit')
|| die Win32::OLE->LastError();

   $Excel->{DisplayAlerts}=0;

#my $Book = $Excel->Workbooks->Open($excelfile) or die
my $Book = $Excel->Workbooks->Add() or die Win32::OLE->LastError();

Win32::OLE->LastError();

print Win32::OLE->LastError();

The output I got reads:

C:\Documents and Settings\dln1\My Documents\White Papers\AANC>perl
test2.pl
LISTING C:\tmp\Book1.xls
 Volume in drive C is LOCAL DISK
 Volume Serial Number is 9C3D-51DA

 Directory of C:\tmp

10/30/2002  10:17a  13,824 Book1.xls
   1 File(s) 13,824 bytes
   0 Dir(s)   8,263,262,208 bytes free
Win32::OLE(0.1502) error 0x80070005: "Access is denied"
in PROPERTYPUT "DisplayAlerts" at test2.pl line 17

Thanks,
Daniel

-Original Message-----
From: Charbeneau, Chuck [mailto:CCharbeneau@;lear.com]
Sent: Wednesday, October 30, 2002 12:48 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Excel, OLE, and Activestae PERL 5.6.1 rel 633 on Windows
2K.


> From: Daniel Needles [mailto:daniel.needles@;Callisma.com]
> Subject: RE: Excel, OLE, and Activestae PERL 5.6.1 rel 633 on
> Windows 2K.
>   Thanks for the response. Sorry about that. I sent the message out
> before checking monks again.

Can you change the Open to just ->Add(); ?

This way we can start to check to see if it's a File issue, or maybe
you
have issues with running as system or a named user.


use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3; # Die on Errors.

my $excelfile = 'book1.xls';

my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit')
  || die Win32::OLE->LastError();

   $Excel->{DisplayAlerts}=0;

my $Book = $Excel->Workbooks->Add() or die Win32::OLE->LastError();

printf("The Last error was - %s",Win32::OLE->LastError());

Let's see if it's a file issue or an Excel issue.

Chuck.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Excel, OLE, and Activestae PERL 5.6.1 rel 633 on Windows 2K.

2002-10-31 Thread Carl Jolley

On Wed, 30 Oct 2002, Daniel Needles wrote:

> Hello,
>
> The following program:
>
>   use strict;
>   use warnings;
>   use Win32::OLE;
>   my $xlfile ='c:\tmp\Book1.xls';
>   my $xl_app = Win32::OLE->new("Excel.Application");
>   $xl_app->{'Visible'} = 0;
>   my $workbook = $xl_app->Workbooks->Open($xlfile);
>   my $worksheet = $workbook->Worksheets(1);
>   my $cellA1 = $worksheet->Range("A1")->{'Value'};
>   my $cellB1 = $worksheet->Range("B1")->{'Value'};
>   print "Cell A1 = $cellA1";
>   $worksheet->Range("A1")->{'value'} = "01aBcD2";
>   $cellA1 = $worksheet->Range("A1")->{'Value'};
>   print "\nCell A1 = $cellA1";
>   $cellA1 =  uc $cellA1;
>   print "\nCell A1 = $cellA1";
>   $xl_app->ActiveWorkbook->Close(0);
>   $xl_app->Quit();
>
> Results in the error
>
> C:\Documents and Settings\dln1\AANC>perl test.pl
>
>   Win32::OLE(0.1502) error 0x80070005: "Access is denied" in
> PROPERTYPUT "Visible" at test.pl line 6
>   Win32::OLE(0.1502) error 0x80070005: "Access is denied" in
> METHOD/PROPERTYGET "" at test.pl line 7
>   Can't call method "Open" on an undefined value at test.pl line 7.
>
> How can I diagnose this problem?
>

By looking at your source code and recognizing that you don't have any
error checking. For a start I would insert the following line after
your Win32::OLE->new call:

die "can\'t create Excel application: $!" unless ref $xl_app eq 'Win32::OLE';

 [EMAIL PROTECTED] 
 All opinions are my own and not necessarily those of my employer 


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs