Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel instantiation and Illegal Operation Error
Message
 
To
03/02/1999 20:46:47
Carol Adler
U.S. Army Kwajalein
Apo, Marshall Islands
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00183729
Message ID:
00183746
Views:
18
Carol,
This works for me:

tmpsheet = getObject('','excel.application')
oExcel = tmpsheet.application

oExcel.workbooks.Open(cFile) && Where cFile is my temp. data

........ && Do stuff here

OExcel.workbooks(1).close(.t.)
OExcel.quit
Release OExcel

Most of it I got by running an Excel macro and looking at the macro code.

HTH
Barbara


>I wanted to check to see if an instance of Excel was already running ,and if so, don't open a new one, but open the document. If not, then open a new instance of Excel.
>
>I have it figured out in Word, but not in Excel.
>
>------------------
>
>Next problem: VFP(5.0a) takes the data from the view (finance_report) and dumps it into the file text.xls, opens Excel, selects all, autofits the columns, and places the selection in cell A1.
>
>The user will then "Send" the document. If I Exit out of Excel, everything is great and I'm returned to VFP. However, if I close the document, I am returned to VFP with an 'illegal operation' error from Excel.
>
>How do I handle this?
>-----------------------------
>Here's my code:
>
>USE finance_report in 0
>copy fields except travnbr_b,travnbr_c to c:\temp\text.xls type xls
>IF TYPE("oExcel") != "O"
> PUBLIC oExcel
> oExcel=createobject("Excel.Application")
>ENDIF
>oExcel.Workbooks.Open("C:\Temp\text.xls")
>oExcel.visible = .t.
>oExcel.cells.select
>oExcel.selection.columns.autofit
>oExcel.range("A1").select
>Release oExcel
Barbara Paltiel, Paltiel Inc.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform