Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating spreadsheets
Message
De
14/07/2002 14:42:08
Alan Harris-Reid
Baseline Data Services
Devon, Royaume Uni
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Creating spreadsheets
Divers
Thread ID:
00678510
Message ID:
00678510
Vues:
49
Using OLE automation, I am using VFP7 (SP1) to create and populate a spreadsheet in Excel 2002.

1. Once the sheet is created I sometimes wish to look at it by double-clicking on the .xls file in Windows explorer. With the VFP session still open (eg. waiting at the command line), Excel starts-up, but then 'freezes' before the sheet is displayed. However, if I quit VFP completely and then double-click on the file, Excel opens the file with no problems. Has anyone else come across this 'clash' of Excel not opening properly when VFP is open?

I have no problems opening simultaneous sessions of VFP and Excel before my program runs, so I guess it is not closing Excel properly, despite the fact that there is an oXL.quit command near the end of the program.

Here is the code...

PUBLIC oXL && cannot be LOCAL in this case

oXL = CREATEOBJECT("Excel.Application") && Start Excel
oXL.Workbooks.Add && create a workbook
oXL.ActiveWorkbook.SaveAs('MySheet') && assign name

* Fill cell contents of sheet 1 here

* Close spreadsheet
oXL.ActiveWorkBook.Save
oXL.Quit && quit Excel


2. The OLE-created spreadsheet by default has 3 sheets. Do I have to delete sheets 2 and 3 programmatically, or is there a way to create the workbook with one sheet only? Come to think of it, do I have to create a workbook at all? Can I create a single sheet by itself?

Any help would be appreciated.
Alan
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform