Embedding objects( txt, doc) into excel using python

Girish girish.14 at gmail.com
Thu May 31 04:23:40 EDT 2007


Hi,

I want to embed  a txt document into an excel using python.

Here is my code, but i get an error message
===================================================
Traceback (most recent call last):
  File "C:\Documents and Settings\kusumap\Desktop\Girish.py", line 7,
in ?
    worksheet.OLEObjects.Add(Filename="C:\Documents and Settings
\kusumap\My Documents\desktop.ini", Link=False,DisplayAsIcon=True,
IconFileName="packager.exe", IconIndex=0, IconLabel="C:\Documents and
Settings\kusumap\My Documents\desktop.ini").Select
AttributeError: 'function' object has no attribute 'Add'
===================================================

import win32com.client
ExcelApp = win32com.client.Dispatch("Excel.Application")
ExcelApp.visible = 1
workbook = ExcelApp.Workbooks.open("C:\Software\New Microsoft Excel
Worksheet.xls")
worksheet = workbook.Activesheet
#worksheet.OLEObjects.Add(Filename="C:\Documents and Settings\p\My
Documents\desk.txt", Link=False,DisplayAsIcon=True,
IconFileName="packager.exe", IconIndex=0, IconLabel="C:\Documents and
Settings\p\My Documents\desk.txt").Select

Can anyone please whtz the problem with the code and how to overcome
the same.

Thanks
Girish S




More information about the Python-list mailing list