By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

How to learn to use python with Excel

P: n/a
I don't like VBA, and want to use python to work with Excel. Does
anybody recommend some good documents to begin with?

Many thanks,

Xiao-Qin
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 2004-09-01, Xiao-Qin Xia <xx**@skcc.org> wrote:
I don't like VBA, and want to use python to work with Excel. Does
anybody recommend some good documents to begin with?

Many thanks,

Xiao-Qin

http://www.reportlab.com/ftp/talks/P...wsTutorial.doc
--
Tomasz Drobiszewski
id***@gazeta.usun.spam.pl
Jul 18 '05 #2

P: n/a
Xiao-Qin Xia wrote:
I don't like VBA, and want to use python to work with Excel. Does
anybody recommend some good documents to begin with?


Mark Hammond and Andy Robinson's book
(http://www.oreilly.com/catalog/pythonwin32/index.html) has good
coverage of such things. You can even read it online if you
subscribe to Safari.

There are also probably dozens of examples you can find on the
net here and there, or in the newsgroup/mailing list archives.
For example, this search should get you started:
http://groups.google.com/groups?q=gr...el.application

-Peter
Jul 18 '05 #3

P: n/a
On 1 Sep 2004, Xiao-Qin Xia wrote:
I don't like VBA, and want to use python to work with Excel. Does
anybody recommend some good documents to begin with?


As a quick-start example, this Python:

from win32com.client import Dispatch
excel = Dispatch("Excel.Application")

is equivalent to this VB:

Dim excel As Application
excel = CreateObject("Excel.Application")

After that, some calls even look identical:

ws = excel.ActiveSheet

eqv. to:

Dim ws as Worksheet
ws = excel.ActiveSheet

Any differences (I can't think of any off the top of my head) will likely
be found through trial and error... one major difference is that, in
addition to properties, VB doesn't want parenthesis after Sub calls
(functions of no arguments), whereas Python does. Fortunately it's pretty
easy to tell with Python; you'll either get a function object or an error
if you guess wrong (as I may have above).

win32com is included in the ActiveState distribution; if you otherwise
don't have it (unlikely), you can download it at
http://www.python.org/windows/win32com/.

Hope this helps.

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.