Nalina has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,
I am using WIn32::OLE to export a graph from Excel to png. the script is as follows
use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); use Win32::OLE; use Win32::OLE::Const; $Win32::OLE::Warn = 3; # die on errors... $file = "C:\\testw.txt"; open (TTT, ">$file") || die "error"; $filename = "C:\\book1.xls"; $filter = 'PNG'; # can be GIF, JPG, JPEG or PNG $pngnm = "C:\\test"; #eval{ my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); # use the Ex +cel application if it's open, otherwise open new print TTT Win32::OLE->LastError(); my $Book = $Excel->Workbooks->Open( $filename ); # open the file foreach my $Sheet (in $Book->Sheets) { # loop through all sheets foreach my $ChartObj (in $Sheet->ChartObjects) { # loop through all chartobjects in the sheet #$datewk = join("".split(/\s+/, $Date)); $savename = "$pngnm" . ".$filter"; #$savename = "$dirpath\\$pngnm" . ".$filter"; # Write image to PNG file $ChartObj->Chart->Export({ FileName => $savename, FilterName => $filter, Interactive => 0 }); } } $Book->Close({SaveChanges=>0}); #}; END { print TTT Win32::OLE->LastError(); }
This script is being called in ASP by Shell Object.
I get an error saying
Win32::OLE(0.1701) error 0x80070005: "Access is denied"
Is this because of improper IIS configuration? Please help me.
Thanks in advance

Replies are listed 'Best First'.
Re: Win32::OLE(0.1701) error 0x80070005
by sk (Curate) on Aug 10, 2005 at 06:42 UTC
    Nalina,

    I can confirm this is not related to Perl. I ran your scirpt on a test XL file (as stand alone) and it created the PNG file just fine. I guess the issue is with the IIS Conf... I am not familiar with IIS but guessing - is IIS running with adequate perms to create the file?

    Can you write your file to some public directory. Will Inetpub work out better?

    cheers

    SK

      How will I check that?
        A bit off topic for a Perl forum, however, IIS generally runs (anonymously anyway) with the IUSR_machinename local user.

        You will need to check two places for permissions: firstly open the web site in the IIS admin tool and make sure the permissions are set to allow write access. Then open the directory in the file system where you're trying to write to and ensure that the IUSR_machinename account has write access to the directory. It may also need read/write access higher up the directory tree as well depending on your configuration.

        You could also turn auditing on those directories and check the security event log to see exactly where it's being denied if this doesn't work.

        HTH,
        Loki

        I am sorry I am afraid I am not the right person to give you info on IIS (never used it before). You might want to try an IIS forum or maybe someone in PM who knows IIS very well can help. Since this is not actually related to Perl, i am not sure whether you will get too many responses!

        Good luck!