Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I detect if Excel is already running?
Message
From
17/11/1998 02:37:48
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00158064
Message ID:
00158160
Views:
20
>>>>How can I change the code to detect if Excel is already running and, if so, simply add a new Workbook to the existing Excel application.
>>>>
>>>
>>>Instead of CREATEOBJ(), use GETOBJECT(), which will use an existing instance of the server if it's available, or start one if it isn't:
>>>
>>>oExcel=GETOBJECT(,'Excel.Application')
>>
>>Thanks for the suggestion. I tried but got the following error message
>>
>>Error number: 0
>>Error message: OLE error code 0x800401e3: Operation unavailable.
>>Line of code with error: oExcel = GETOBJECT(, "Excel.Application")
>
>Upon further investigation, oExcel = GETOBJECT(, "Excel.Application") does work if Excel is already running.
>
>If an instance of Excel is not yet running then I get the OLE error code. I can trap the error and do a CREATEOBJECT() if the error occurs but why should I need to do this when GETOBJECT() is supposed to create an instance if one is not yet running?
>
>Any ideas why GETOBJECT() is not creating an instance of Excel? (I am using VFP5.0a)
>
>thanks,
>
>Alain
Alain,
If you call getobject("","Excel.Application") it works though an Excel is not active. But OTOH it doesn't mean that it would invoke an existing Excel session if the other session is not started from within VFP. You could check it with WINAPI - isrun32.zip in files\classes section - but I don't know then how would you have a ref to it VFP :(
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