public oleapp,oExcel gfile=getfile("xls") If !empty(gfile) oExcel = createobject("Excel.Application") With oExcel .Workbooks.Open(gFile) .visible=.t. EndWith EndifYou will see that Excel sticks around. Also, your automation code can be simplified a bit...
gfile=getfile("xls") If !empty(gfile) Thisform.oExcel = createobject("Excel.Application") With Thisform.oExcel .Workbooks.Open(gFile) .visible=.t. EndWith EndifThe key is to make sure the variable that holds a reference to the automation server remains in scope. Otherwise, the instance gets destroyed.