locked
Program Crashes when opening Excel sheet RRS feed

  • Question

  • Hello

    I have recently upgraded to a Windows 10 machine running office 2013. My FoxPro program crashes with a error of WINDOWS undefined. I am opening the Excel file with OLE (I believe) using the attached code. I also include a Excel.h file. After I get the error message if I try and debug it FoxPro crashes.

    obook = Getobject(xlsfile)
    * Open the workbook
    With obook
     oexcel = .Application
     .Application.Visible = .T.
     .Windows[1].Activate()
     osheet1 = .sheets[1]
    Endwith
    With oexcel

    Tuesday, October 4, 2016 5:45 PM

Answers

  • If I do this for an XLSX up to the point the application is set visible, I get 2 empty windows. This looks weird and incompletely loaded, in some not stable state.

    You better automate this the usual way:

    oExcel=CreateObject("Excel.Application")
    oBook = oExcel.Workbooks.Open(xlsFile)

    I don't see why you would want to activate any window. You can be sure the last opened xls(x) file will be the oExcel.ActiveWorkbook.

    Bye, Olaf.


    Olaf Doschke - TMN Systemberatung GmbH

    • Proposed as answer by Naomi N Wednesday, October 5, 2016 1:24 PM
    • Marked as answer by Steve R-801 Friday, October 7, 2016 5:33 PM
    Wednesday, October 5, 2016 1:21 PM

All replies

  • Can you comment this line

    .Windows[1].Activate()

    and see if you can get by.


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


    My TechNet articles

    Tuesday, October 4, 2016 5:47 PM
  • I tried that as well, I then get a OLE error code 0x800a03ec:Unknown Com status code when I select the sheet number.
    Tuesday, October 4, 2016 8:11 PM
  • Most probably you have a new excel (office) instalation as well.

    Make sure The dbf file are not blocked from being opened via excel

    Under File-Option-Trust Center-Trust Center Advanced

    Wednesday, October 5, 2016 12:58 PM
  • If I do this for an XLSX up to the point the application is set visible, I get 2 empty windows. This looks weird and incompletely loaded, in some not stable state.

    You better automate this the usual way:

    oExcel=CreateObject("Excel.Application")
    oBook = oExcel.Workbooks.Open(xlsFile)

    I don't see why you would want to activate any window. You can be sure the last opened xls(x) file will be the oExcel.ActiveWorkbook.

    Bye, Olaf.


    Olaf Doschke - TMN Systemberatung GmbH

    • Proposed as answer by Naomi N Wednesday, October 5, 2016 1:24 PM
    • Marked as answer by Steve R-801 Friday, October 7, 2016 5:33 PM
    Wednesday, October 5, 2016 1:21 PM
  • Ok Olaf I will try that way.

    One thing I did find out today, is that the programs work fine when opening a .XLS file


    Steve R @ Plasticolor

    Thursday, October 6, 2016 10:26 PM
  • Thanks Olaf

    that seems to do the trick


    Steve R @ Plasticolor

    Friday, October 7, 2016 5:34 PM