Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel Automation
Message
From
17/07/1999 12:56:50
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
16/07/1999 19:24:27
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00242078
Message ID:
00242761
Views:
21
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform