I create an Excel workbook and launch Excel in my code. The oExcel DefaultFilePath does not always set the FILE->SAVE AS folder location. I have run the following code in the Command window and the pattern seems to be the first time that I change the location, it keeps the old location. Then if I run the code again, it now has in the FILE->SAVE AS the new folder location. When I am in Excel I am doing nothing other than looking at the FILE->SAVE AS and then closing the application.
site_id = '10'
cDirectory = rpath + '\Query_Maker\r' +ALLTRIM(site_id)+'\'
RELEASE oexcel
oExcel = CREATEOBJECT('Excel.Application')
oExcel.DefaultFilePath = cDirectory
oExcel.Workbooks.Add
oexcel.Visible = .t.