Skip to content

passing a workbook as an argument in macro call #784

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

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

passing a workbook as an argument in macro call #784

BricksBurg opened this issue Dec 6, 2017 · 3 comments
Milestone

Comments

@BricksBurg
Copy link

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
Copy link
Member

can you paste the function definition of Function1?

@BricksBurg
Copy link
Author

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

@skasi7
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants