Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Calling Excel module functions from python [repost]

Reply
Thread Tools

Re: Calling Excel module functions from python [repost]

 
 
Mark Carter
Guest
Posts: n/a
 
      07-10-2003
Koczian <(E-Mail Removed)-Augsburg.de> wrote in message news:<bejgq8$9j8$(E-Mail Removed)-augsburg.de>...
> Mark Carter schrieb:
>
> > In Excel, I have a module named modCSV which has a function named
> > SaveSheet(), which I want to be able to call from python. How do I do
> > it?
> >
> > I've opened the workbook containing the module, and executed the code:
> >
> > from win32com.client import Dispatch
> > xlApp = Dispatch("Excel.Application")
> > xlApp.Visible = 1
> > wb = xlApp.ActiveWorkbook
> > wbc = wb.VBProject.VBComponents("modCSV")
> > wbc.SaveSheet()
> >
> > but I get the error message:

[snip]

> Try
>
> xlApp.Run('SaveSheet')


It works!


> That works with ordinary Excel macros, but I don't know about
> VBProject.VBComponents. Possibly this might work:
>
> wbc.Run('SaveSheet').


It doesn't work. But that doesn't matter, because the first method works.

A further tip:
For a function taking arguments, use
xlApp.Run("func", "arg1", "arg2", ...)

Thanks
 
Reply With Quote
 
 
 
 
Koczian
Guest
Posts: n/a
 
      07-11-2003
Mark Carter schrieb:
> A further tip:
> For a function taking arguments, use
> xlApp.Run("func", "arg1", "arg2", ...)
>

Thank you! That was something I tried to get right some weeks ago but
gave up on. Moral: don't give up, ask around.

Koczian

--
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410
e-mail : http://www.velocityreviews.com/forums/(E-Mail Removed)-Augsburg.DE

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Python functions from Excel Cannonbiker Python 8 11-18-2009 06:38 PM
Problem with Excel reports ::::Excel 2003 Migration To Excel 2007 =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= ASP .Net 15 10-24-2007 01:34 PM
Calling Access module functions from python kayakerjess Python 1 09-23-2005 04:29 PM
Calling Access module functions from python kayakerjess Python 0 09-21-2005 03:26 PM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM



Advertisments