Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Closing a link to an Excel app
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00748912
Message ID:
00748928
Vues:
25
This message has been marked as the solution to the initial question of the thread.
With CREATEOBJECT you initialize the EXCEL.exe. Therefore when you close the workbook, the Excel is still running. After closing workbook, you need to add:

.hoExcelApp.QUIT

Actually I can not see the reason here to use Workbook.close method because you are not going to change/save the xls file.
Also just a precaution to avoid any Excel messages that require user interaction, add in the beginning:

.hoExcelApp.DisplayAlerts = .f.


>I've got a little utility that uses OLE to open and interogate an Excel spreadsheet in VFP.
>
>An abstract of my methodology:
>
>WITH THIS
> m.lcSrcXLS = GETFILE('XLS')
>
> .hoExcelApp = CREATEOBJECT("Excel.Application")
>
> IF NOT ISNULL(.hoExcelApp)
> WITH .hoExcelApp
> .Workbooks.Open(m.lcSrcXLS, .F., .T.) && readonly
> .Workbooks[THIS.pnXlsWorkbook].Activate()
> .Worksheets[THIS.pnXlsSpreadsheet].Activate()
> ENDWITH
>
> *** get information from the Excel spreadsheet
>
> .hoExcelApp.WorkBooks(.pnXlsWorkbook).Close()
> .hoExcelApp = .NULL.
> ENDIF
>ENDWITH
>
>My problem is that when I leave the program, VFP still has a lock on the XLS file. I would have thought that the Closee() method would have broken the link into the XLS file, and NULLing the Excel object should have broken any ties to Excel.
>
>What's missing?
>
>TIA
>Thom C.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform