Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to work around VFP Excel Page Fault?
Message
From
27/07/1999 08:45:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00246455
Message ID:
00246523
Views:
15
>>>My VFP6 Excel automation project:
>>>oExcel=createobject('Excel.Application')
>>>oExcel.Application.WorkBooks.Open('MYXLS.XLS')
>>>oExcel.Application.Run('Auto_Start')
>>>oExcel.Visible=.t.
>>>Behaves well, and does the job! I can close the session without incident, by simply clicking Excel's main (X) close. BUT, when I click the "workbooks" (X) close, Window's returns an EXCEL.EXE caused a page fault at 157 ...
>>>
>>>Something similar too: oExcel.Application.WorkBooks(1).Closable=.f., (BTW this did not work) would be helpful. Is it possible to disable the "sheet's" (X) close, and force to click Main's (X) Close?
>>>
>>>Thank you,
>>Yeah that caused me to lose a lot of time too. My workaround was like this :
lcExcelFile = "myxls.xls"
>>oExcel = createobject("Excel.application")
>>WITH oExcel
>>*....
>>ENDWITH
>>myHandle = fopen(lcExcelFile,12)
>>do while myHandle < 0
>>  myHandle = fopen(lcExcelFile,12) && Try to open temp xls read-write
>>enddo
>>=fclose(myHandle) && Excel released it
>>Release oExcel
Cetin
>
>I see only one problem here - if the file is deleted by Excel (or some other unanticipated or uncontrolled app) you might get hung. I'd change the DO WHILE to allow for this; maybe:
>
>DO WHILE FILE(lcExcelFile) AND myHandle < 0
>
>since FOPEN() of a non-existant file will return -1
You're right Ed. On our project it wasn't an option so I didn't bother an error checking.
Surprisingly my former code was WinAPI based checking IsWindow. Unfortunately IsWindow returns .t. when Sheet is closed first.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform