From: Warren S. <ws...@tr...> - 2006-02-28 20:54:00
|
I have a PythonCard app that opens up an Excel spreadsheet using the win32com module. =20 I started doing this in Perl, then recently switched to Python (and PythonCard), which I am just learning. =20 In Perl, I found the following code snippet which I used in my app: =20 ---------------------- # use existing instance if Excel is already running eval {$ex =3D Win32::OLE->GetActiveObject('Excel.Application')}; die "Excel not installed" if $@; unless (defined $ex) { $ex =3D Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die "Oops, cannot start Excel"; $ex->{Visible} =3D 1; } # Note the destructor specified on the Win32::OLE->new method.=20 # It ensures that Excel will shutdown properly even if the Perl program dies. ---------------------- =20 I would like to be able to do the same in Python, but don't know if it is supported, and can't find or figure out the syntax if it is. =20 I know this is not really a PythonCard question, but I'm hoping that other PythonCard users are working with win32com and might be able to help me out. =20 My code to open the excel object is simply this: =20 ---------------------- import win32com as wc ... =20 self.xl =3D wc.Dispatch("Excel.Application") self.xl.Visible =3D 1 ... =20 self.xl.Quit() ---------------------- =20 Warren Sande =20 |