title: Win32com Save PDF to XML with Acrobat Pro X > com_error "-2147467263, 'Not implemented'"
body: <ul>
  <li>Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32</li>
  <li>Windows XP SP3</li>
  <li>Python 2.7 pywin32-218</li>
  <li>Adobe Acrobat X 10.0.0</li>
  </ul>
  
  <p>I want to use Python to automate Acrobat Pro to export a PDF to XML. I already tried it manually using the 'Save As' dialog box from the running program and now want to do it via a Python script. I have read many pages including parts of the Adobe SDK, SDK Forum, VB Forums and am having no luck.</p>
  
  <p>I read Blish's problem here: <a href="https://stackoverflow.com/questions/9383307/not-implemented-exception-when-using-pywin32-to-control-adobe-acrobat">&quot;Not implemented&quot; Exception when using pywin32 to control Adobe Acrobat</a></p>
  
  <p>And this page: timgolden  python/win32_how_do_i/generate-a-static-com-proxy.html</p>
  
  <p>I am missing something. My code is:</p>
  
  <pre><code>import win32com.client
  import win32com.client.makepy
  
  win32com.client.makepy.GenerateFromTypeLibSpec('Acrobat')
  adobe = win32com.client.DispatchEx('AcroExch.App')
  avDoc = win32com.client.DispatchEx('AcroExch.AVDoc')
  avDoc.Open('C:\Documents and Settings\PC\Desktop\a_PDF.pdf', 'C:\Documents and Settings\PC\Desktop')
  pdDoc = avDoc.GetPDDoc()
  jObject = pdDoc.GetJSObject()
  jObject.SaveAs('C:\Documents and Settings\PC\Desktop\a_PDF.xml', "com.adobe.acrobat.xml-1-00")
  </code></pre>
  
  <p>The full error is:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;pyshell#31&gt;", line 1, in &lt;module&gt;
      jObject.SaveAs('C:\Documents and Settings\PC\Desktop\a_PDF.xml', "com.adobe.acrobat.xml-1-00")
    File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 511, in __getattr__
      ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
  com_error: (-2147467263, 'Not implemented', None, None)
  </code></pre>
  
  <p>I'm guessing it has to do with make.py but I don't understand how to implement it in my code.</p>
  
  <p>I pulled this line from my code and got the same error when I ran it:</p>
  
  <pre><code>win32com.client.makepy.GenerateFromTypeLibSpec('Acrobat')
  </code></pre>
  
  <p>I then changed these two lines from 'DispatchEX' to 'Dispatch' and same error:</p>
  
  <pre><code>adobe = win32com.client.Dispatch('AcroExch.App')
  avDoc = win32com.client.Dispatch('AcroExch.AVDoc')
  </code></pre>
  
  <p>When I run the Dispatches by themselves and then call them back I get:</p>
  
  <pre><code>&gt;&gt;&gt; adobe = win32com.client.DispatchEx('AcroExch.App')
  &gt;&gt;&gt; adobe
  &lt;win32com.gen_py.Adobe Acrobat 10.0 Type Library.CAcroApp instance at 0x18787784&gt;
  &gt;&gt;&gt; avDoc = win32com.client.Dispatch('AcroExch.AVDoc')
  &gt;&gt;&gt; avDoc
  &lt;win32com.gen_py.Adobe Acrobat 10.0 Type Library.CAcroAVDoc instance at 0x20365224&gt;
  </code></pre>
  
  <p>Does this mean I should make only one call to Dispatch? I pulled:</p>
  
  <pre><code>adobe = win32com.client.Dispatch('AcroExch.App')
  </code></pre>
  
  <p>and got the same error.</p>
  
  <p>This Adobe site says:</p>
  
  <pre><code>AVDoc    
  Product availability: Acrobat, Reader
  Platform availability: Macintosh, Windows, UNIX
  Syntax
  typedef struct _t_AVDoc* AVDoc;
  
  A view of a PDF document in a window. There is one AVDoc per displayed document. Unlike a PDDoc, an AVDoc has a window associated with it.
  </code></pre>
  
  <ul>
  <li>acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/API_References/Acrobat_API_Reference/AV_Layer/AVDoc.html#AVDocSaveParams</li>
  </ul>
  
  <p>The PDDoc page says:</p>
  
  <pre><code>A PDDoc object represents a PDF document. There is a correspondence between a PDDoc and an ASFile. Also, every AVDoc has an associated PDDoc, although a PDDoc may not be associated with an AVDoc.
  </code></pre>
  
  <ul>
  <li>/9.1/Acrobat9_1_HTMLHelp/API_References/Acrobat_API_Reference/PD_Layer/PDDoc.html</li>
  </ul>
  
  <p>I tried the following code and also got the same error:</p>
  
  <pre><code>import win32com.client
  import win32com.client.makepy
  
  pdDoc = win32com.client.Dispatch('AcroExch.PDDoc')
  pdDoc.Open('C:\Documents and Settings\PC\Desktop\a_PDF.pdf')
  jObject = pdDoc.GetJSObject()
  jObject.SaveAs('C:\Documents and Settings\PC\Desktop\a_PDF.xml', "com.adobe.acrobat.xml-1-00")
  </code></pre>
  
  <p>Same error if I change:</p>
  
  <pre><code>pdDoc = win32com.client.Dispatch('AcroExch.PDDoc')
  </code></pre>
  
  <p>to</p>
  
  <pre><code>pdDoc = win32com.client.gencache.EnsureDispatch('AcroExch.PDDoc')
  </code></pre>
  
  <p>like here: <a href="https://stackoverflow.com/questions/11623461/win32com-client-dispatch-works-but-not-win32com-client-gencache-ensuredispatch">win32com.client.Dispatch works but not win32com.client.gencache.EnsureDispatch</a></p>