[python-win32] Excel and OLEObjects

Mark Norley m_norley_newsgroups at yahoo.co.uk
Mon Oct 30 14:02:18 CET 2006


Hello

I'm trying to insert an object into an Excel sheet with the following code:

import win32com.client
xlapp = win32com.client.Dispatch("Excel.Application")
xlapp.Visible = 1
xlapp.Workbooks.Add()
xlapp.ActiveSheet.OLEObjects.Add(FileName = "C:\\mytext.tx"', Link=False,
DisplayAsIcon=False).Select

But I get: AttributeError: 'function' object has no attribute 'Add'

If I record a macro in Excel for what I want to do it comes out as:

Sub Macro1()
'
' Macro2 Macro
' Macro recorded 30/10/2006 by Mark
'

'
    ActiveSheet.OLEObjects.Add(Filename:="C:\mytext.txt", Link:=False, _
        DisplayAsIcon:=False).Select
End Sub

I'm a complete COM noob...what am I doing wrong?

Cheers
Mark

WinXP SP2
Python 2.4.2
Pywin32 210
Excel 2003


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.17/505 - Release Date: 27/10/06
 


		
___________________________________________________________ 
Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html


More information about the Python-win32 mailing list