Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I cannot close Excel.application
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00656380
Message ID:
00658139
Views:
35
Helen,

Hmmm... What I see seems to be OK. I don't think it has to do with the 9th
column I do a lot more sometimes and that's normally not the problem.

There is a restriction in the Rowcount of excel but that parameter seems
to be ok as well (are there 1.700 or 17.000 records? In Your request You
had both mentioned)

What I do, when playing with Excel is, to make it visible until I am
sure it runs properly. I would do
loExcel.Visible = .T.

Maybe there is a problem with implicitly used objects. You are always
referencing the Application-Object. I don't know if it matters, but I
am directly referencing the Sheet I'm working with.

Normally I start like this
    *-- Create a reference to an Excel OLE object
    XLApp = CREATEOBJECT('Excel.Application')

    *-- Create a reference to a workbook
    oMyXLWorkbook = XLApp.Application.Workbooks.Add

    *-- Create a reference to a worksheet    
    XLSheet      = oMyXLWorkbook.Worksheets.Add

    with xlApp
        *-- I only need one sheet, so throw away
        *-- the others
        .DisplayAlerts = .F.
        .ActiveWorkBook.Worksheets(3).Delete
        .ActiveWorkBook.Worksheets(2).Delete
        
        *-- This also works       
        *-- .ActiveWorkBook.Worksheets(2).Delete
        *-- .ActiveWorkBook.Worksheets(2).Delete

        *-- Alarm wieder an
        .DisplayAlerts = .T.
    endwith        


    *-- Position the Excel Application window so you can still see VFP's
    *-- application window behind it.
    *-- WITH XLApp
    *--     .Height = 220
    *--     .Width  = 540
    *--     .Left   = 0
    *--     .Top    = 220
    *-- ENDWITH
        
    *-- Show the object so we can see what is happening.
    XLApp.Visible = .T.

    *-- now do the stuff
    with xlsheet
        ....
    endwith


    *-- And when done, save and clean up
    if ! empty(lc_XLSFile)
        xlSheet.SaveAs(lc_xlsFile)
    endif

    if MessageBox(;
     "Would you like to edit the Excel-Sheet now?", ;
     32+4, "Question") # 6
        xlApp.Quit
    else
        xlApp.Visible = .T.
    endif    

    xlSheet         = .NULL.
    oMyXLWorkbook   = .NULL.
    xlApp           = .NULL.
Are You sure, You do not have any temporary object-references
dangling around?

Maybe You can remove the

loExcel.Application.Quit

You are writing the Header-Info using range-objects.
Try to use .Cells(1, ln_col) as You do in the scan.
(no idea if it makes a difference, just a quess)

HTH
Regards from Berlin

Frank

Dietrich Datentechnik (Berlin)
Softwarekombinat Teltow (Teltow)

Frank.Dietrich@dd-tech.de
DFPUG # 327
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform