in reply to Re: How to resize a column in excel with Win32::OLE
in thread How to resize a column in excel with Win32::OLE

Thanks for your response.

Your suggestion seems to be correct. since I am selecting the whole column, A1 seems wrong.

I changed the code to $worksheet->Columns("A"); but it crashed again. This time the error message was

Win32::OLE(0.1502) error 0x80020009: "Exception occurred" in PROPERTYPUT "ColumnWidth" at ole.pl line 10 quitting Microsoft Excel

regards,
Abhishek.
  • Comment on Re: Re: How to resize a column in excel with Win32::OLE

Replies are listed 'Best First'.
Re: Re: Re: How to resize a column in excel with Win32::OLE
by jmcnamara (Monsignor) on Feb 06, 2003 at 14:11 UTC

    Sorry, that should have been $worksheet->Columns("A:A"). Here is a working example:
    #!/usr/bin/perl -w use strict; use Cwd; use Win32::OLE; my $application = Win32::OLE->new("Excel.Application"); my $workbook = $application->Workbooks->Add; my $worksheet = $workbook->Worksheets(1); $worksheet->Cells(1,1)->{Value} = "Hello World"; $worksheet->Columns("A:A")->{ColumnWidth} = 25; # Get current directory using Cwd.pm my $dir = cwd(); $workbook->SaveAs($dir . '/win32ole.xls'); $workbook->Close;

    --
    John.