Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing a workbook as an argument in macro call #784

Closed
BricksBurg opened this Issue Dec 6, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@BricksBurg
Copy link

BricksBurg commented Dec 6, 2017

I am trying to call an external macro in a workbook which requires the workbook as a parameter although I get the following error:
"TypeError: Objects of type 'Book' can not be converted to a COM VARIANT (but obtaining the buffer() of this object could)"

Here is the code:
import xlwings as xw
...
wb = xw.Book(FILEPATH)
macro1 = wb.app.macro("libraryfunctions.xlam!Function1")
macro1(wb)

@fzumstein

This comment has been minimized.

Copy link
Member

fzumstein commented Dec 6, 2017

can you paste the function definition of Function1?

@BricksBurg

This comment has been minimized.

Copy link
Author

BricksBurg commented Dec 6, 2017

Sure it's:
Public Function Function1(oWorkbook As Workbook) As Boolean

@skasi7

This comment has been minimized.

Copy link
Contributor

skasi7 commented Jan 29, 2018

A wild guess, check if passing wb.api instead of wb fixes your problem. Maybe wb.api can be passed as COM VARIANT.

@fzumstein fzumstein added this to the 0.15.5 milestone Mar 25, 2019

@fzumstein fzumstein closed this in 9987daa Mar 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.