IEC - cannot find button

kyosohma at gmail.com kyosohma at gmail.com
Mon Oct 29 09:04:41 EDT 2007


On Oct 29, 12:58 am, daniel_no... at msn.com wrote:
> I'm brand new to Python--and programming in general. I'm trying to use
> IEC to control Internet Explorer. I've navigated to a page, and now
> I'm trying to click a button. The button appears to be called 'PDF
> Preview' but I honestly do not know whether that's the name or the
> caption. Here is my code:
>
>      from win32com.client import Dispatch
>      import IEC
>
>      .
>      .
>      .
>
>      ie = IEC.IEController(window_num = 1)
>      ie.Navigate(URL_part_1 + x + URL_part_2)
>      ie.ClickButton(name='PDF Preview')
>
> (I've also tried replacing name w/ caption but I get a similar error
> message.) I get this error message:
>
> Traceback (most recent call last):
>   File "C:\Program Files\Python25\experiment", line 14, in <module>
>     ie.ClickButton(name='PDF Preview')
>   File "C:\Program Files\Python25\lib\IEC.py", line 126, in
> ClickButton
>     elem = elemcoll.item(i)
>   File "<COMObject <unknown>>", line 3, in item
> com_error: (-2147024891, 'Access is denied.', None, None)
>
> I really have no idea how to interpret this. I'm pasting the button
> tag below:
>
> <td>
>      <input type="button" value="PDF Preview"
> onclick="javascript:performPdfPreview(2);"/>
> </td>

You might want to look at PAMIE instead. It sounds like a Python
project that's aimed at automating Internet Explorer:
http://sourceforge.net/projects/pamie/

But if you really like COM, I found this tutorial:

http://www.evilbitz.com/2006/10/22/python-ie-automation-thorough-tutorial/

I'm not very good with COM, but I would recommend that you do some
research on it. From the traceback, I would guess that you don't have
administrator privileges (of some sort) on the machine you're running
the script on.

Mike




More information about the Python-list mailing list