Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating spreadsheets
Message
From
14/07/2002 14:42:08
Alan Harris-Reid
Baseline Data Services
Devon, United Kingdom
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Creating spreadsheets
Miscellaneous
Thread ID:
00678510
Message ID:
00678510
Views:
48
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
Next
Reply
Map
View

Click here to load this message in the networking platform