<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.com.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.com-get-active-object.php',
    1 => 'com_get_active_object',
    2 => 'Returns a handle to an already running instance of a COM object',
  ),
  'up' => 
  array (
    0 => 'ref.com.php',
    1 => 'COM Functions',
  ),
  'prev' => 
  array (
    0 => 'function.com-event-sink.php',
    1 => 'com_event_sink',
  ),
  'next' => 
  array (
    0 => 'function.com-load-typelib.php',
    1 => 'com_load_typelib',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/com/functions/com-get-active-object.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">com_get_active_object</span> &mdash; <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="methodname"><strong>com_get_active_object</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$prog_id</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$codepage</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="class.variant.php" class="type variant">variant</a></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.php" 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 &quot;<code class="literal">Running Object Table</code>&quot; 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><code class="parameter">prog_id</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">prog_id</code> must be either the ProgID or CLSID for
       the object that you want to access (for example
       <code class="literal">Word.Application</code>).
      </p>
     </dd>
    
    
     <dt><code class="parameter">codepage</code></dt>
     <dd>
      <p class="para">
       Acts in precisely the same way that it does for the <a href="class.com.php" class="xref">com</a> class.
      </p>
     </dd>
    
   </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><a href="com.constants.php#constant.mk-e-unavailable">MK_E_UNAVAILABLE</a></code></strong>;
   you can use the <code class="literal">getCode</code> method of the exception object
   to check the exception code.
  </p>
 </div>



 <div class="refsect1 changelog" id="refsect1-function.com-get-active-object-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">codepage</code> is nullable now.
      </td>
     </tr>

    </tbody>
   
  </table>

 </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">&raquo;&nbsp;Considerations for Server-Side
    Automation of Office</a> for more information on the general issues
    involved.
   </p>
  </div>
 </div>

</div><?php manual_footer($setup); ?>