SPUG: Newbie problem with Win32::OLE

Bob Hiltner bobhilt at eskimo.com
Fri Dec 1 01:54:11 CST 2000


On Wed, 29 Nov 2000, Tracie Edelson wrote:

> 
> to .csv files. I then open the .csv files in Excel and "save as" Excel files
> (.xls). The whole thing works great, except that when I open the "converted"
> .xls files, the data is no longer columnar (it is a single line separated by
> commas.

Could it be something as simple as the 'visable' typo?  If the sheet is
required to be visible, then this could explain the problem.  (Don't know
enough perl to give anything more definitive...

But one thing I do see is that you might want to move the setting of $ex
to a spot before the loop--no need to re-deal with it for each iteration.
(And, of course, leave the $workbook setting inside the loop...)

Hope this helps.
	-Bob
<snip>

>		foreach($dir){ > 			
> 			use Win32::OLE qw (in with);
> 			use Win32::OLE::Const;
> 			use Win32::OLE::Const 'Microsoft Excel';
> 			$Win32::OLEWarn=3; #die on errors
> 			
> 			$ex  =
> Win32::OLE->GetActiveObject('Excel.Application')
> || Win32::OLE->new('Excel.Application', 'Quit'); # use the Excel application
> if it's open, otherwise open new
> 			$ex->{Visable} =1;
> 			$workbook = $ex->Workbooks->Open("$csvfolder$dir");
> 			$workbook->SaveAs
> ("$xlsfolder$dir.xls")->{FileFormat}=
> xlExcel9795->{ReadOnlyRecommended}=False;
> 			$ex->ActiveWorkbook->Close(0);
> 			}
> $ex->Quit();
> 	}
> }


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list