>Hi Cetin
>
>I got it finally working. After trying many options I finally concluded that it is the GetObject() function which makes the worksheet hidden. The next code (99.99% yours) works great an fast also.
>
>lcFileName = GetFile('xls')
>oExcel= createobject('Excel.application')
>with oExcel
> .WorkBooks.open(lcFileName)
> .Workbooks(1).ActiveSheet.Range("A:D").EntireColumn.AutoFit
> .WorkBooks(1).Save
> .Quit
>endwith
>
>
>Bu the next one, instead of using CreateObject, in contains a GetObject() keeps the file hidden next time you try to open it.
>
>lcFile = GetFile('xls')
>uTMP = GetObject(lcFile)
>oXLSApp = uTMP.application
>with oXLSApp
> .Workbooks(1).ActiveSheet.Range("A:D").EntireColumn.AutoFit
> .workbooks(1).Save
> .Quit
>endwith
>
>If you ever try GetObject and manage to make it work without hiding the worksheet, please let me know. All I got from a debug session was that when you un-hide the worksheet from within Excel, the Saved property changes but I couldn’t notice any other property changed, so it probably changes any other object inside the application, or a property of the application object.
>
>Regards and thanks again
>
>Oscar
Oscar,
Getobject() is used wrongly there (or I should say it's the documents misleading partially ). Getobject() is for (IMHO) preventing another activation of Excel if it's there already. Createobject() activates another one. I code it within a if..endif block to check its existence via winapi and if it's there use getobject() otherwise createobject(). I don't agree with the idea to create a sheet first than access its parent container (oSheet.application). This would hide the sheet as in your case. That's not a problem though :
oApplication.ActiveSheet.visible = .t. && Show
To KISS first do it with createobject(). Later when I have more time I'll send you if..endif block (or to FAQ section with some Excel codes).
Cetin