<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Returns a handle to an already running instance of a COM object</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.com-event-sink.html">com_event_sink</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.com-get.html">com_get</a></div> <div class="up"><a href="ref.com.html">COM Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.com-get-active-object" class="refentry"> <div class="refnamediv"> <h1 class="refname">com_get_active_object</h1> <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">com_get_active_object</span> — <span class="dc-title">Returns a handle to an already running instance of a COM object</span></p> </div> <div class="refsect1 description" id="refsect1-function.com-get-active-object-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="class.variant.html" class="type variant">variant</a></span> <span class="methodname"><strong>com_get_active_object</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$progid</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$code_page</code></span> ] )</div> <p class="para rdfs-comment"> <span class="function"><strong>com_get_active_object()</strong></span> is similar to creating a new instance of a <a href="class.com.html" class="xref">COM</a> object, except that it will only return an object to your script if the object is already running. OLE applications use something known as the "<em>Running Object Table</em>" to allow well-known applications to be launched only once; this function exposes the COM library function GetActiveObject() to get a handle on a running instance. </p> </div> <div class="refsect1 parameters" id="refsect1-function.com-get-active-object-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">progid</code></em></span> <dd> <p class="para"> <em><code class="parameter">progid</code></em> must be either the ProgID or CLSID for the object that you want to access (for example <em>Word.Application</em>). </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">code_page</code></em></span> <dd> <p class="para"> Acts in precisely the same way that it does for the <a href="class.com.html" class="xref">COM</a> class. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.com-get-active-object-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> If the requested object is running, it will be returned to your script just like any other COM object. </p> </div> <div class="refsect1 errors" id="refsect1-function.com-get-active-object-errors"> <h3 class="title">Errors/Exceptions</h3> <p class="para"> There are a variety of reasons why this function might fail, the most common being that the object is not already running. In that situation, the exception error code will be <strong><code>MK_E_UNAVAILABLE</code></strong>; you can use the <em>getCode</em> method of the exception object to check the exception code. </p> </div> <div class="refsect1 notes" id="refsect1-function.com-get-active-object-notes"> <h3 class="title">Notes</h3> <div class="warning"><strong class="warning">Warning</strong> <p class="para"> Using <span class="function"><strong>com_get_active_object()</strong></span> in a web server context is not always a smart idea. Most COM/OLE applications are not designed to handle more than one client concurrently, even (or especially!) Microsoft Office. You should read <a href="http://support.microsoft.com/kb/257757" class="link external">» Considerations for Server-Side Automation of Office</a> for more information on the general issues involved. </p> </div> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.com-event-sink.html">com_event_sink</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.com-get.html">com_get</a></div> <div class="up"><a href="ref.com.html">COM Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>