[Python-Dev] Question about win32com in MS-Excel (original) (raw)

Jiang Yu jiangyu at adtec.com.cn
Fri Aug 13 12:16:05 CEST 2004


Hello, My name is Jiangyu, a Chinese man. You can call me Joe. I learn Python for only one year. I think it's a simple tools in my job some time. But in my country, Python is a new tools for many people. So If i have some problems on it, I found it's difficult to look for the answers。So I add the this mail list.

Now, I have a question about use win32com moudle for MS-Excel. Question: I want to insert a file into a Excel sheet. But a exception occured in my code. Using VBA, I insert a file OK. And the processing in Python is equivalent in VBA.

My environment: Python2.2.3 + win32com + Win2000 Server + Excel(Office XP)

My Python code:

from win32com.client import Dispatch excel = Dispatch("Excel.Application") excel.Visible = 1 excel.WorkBooks.Add() cursheet = excel.ActiveWorkBook.ActiveSheet oleobjs = cursheet.OLEObjects() oleobjs.Add(Filename = r"c:\temp.txt")

My VBA code: ActiveWorkbook.ActiveSheet.OLEObjects.Add Filename:="c:\temp.txt", Link:=False, DisplayAsIcon:=False

So, If you know how to do it. please answer me. Thanks!

joe 2004/8/13 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20040813/12d32d08/attachment.html



More information about the Python-Dev mailing list