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

Automation Error while importing UDF into Excel #566

Closed
vineethbabuR opened this issue Oct 5, 2016 · 16 comments
Closed

Automation Error while importing UDF into Excel #566

vineethbabuR opened this issue Oct 5, 2016 · 16 comments

Comments

@vineethbabuR
Copy link

i created a file using the "xlwings quickstart" command and added the following function in the python file

@xlw.func
def add(x,y):
     return 2 * (x+y)

when i try to import this udf into the excel file, i get a Runtime error 440 Automation error

I am using Python 3.5.2 (32 bit )
error message
vba line in error

my excel is 32 bit pro plus

@fzumstein
Copy link
Member

When you download the Fibonacci sample from the homepage, does that work?

@vineethbabuR
Copy link
Author

Hi Felix,

yes, this works

Vineeth

@fzumstein
Copy link
Member

ok what about the UDF sample then? if you open it and hit Alt-Ctrl-F9?

@vineethbabuR
Copy link
Author

hi,

when i use Alt-Ctrl-F9, i can see the numbers recalculating, but in the same UDF book, if i click on Import Python UDF, i get the same Automation Error message

vineeth

@fzumstein
Copy link
Member

If you hit Alt-F8 and run ImportPythonUDFs from the menu instead of from the addin, do you get the same error? If yes, can you type ?Err.Description into the VBA Immediate window when the code breaks?

@vineethbabuR
Copy link
Author

Hi
Running the macro using Alt-F8 produces the same error, ?Err.Description on immediate pane outputs "Automation error"

@ayemjay
Copy link

ayemjay commented Oct 6, 2016

I received same error when my sheet had an existing named range assigned with same name as my function.

@su79eu7k
Copy link

Please check trust access to the VBA project object model option (File > Options > Trust Center > Trust Center Settings > Macro Settings). In my case, even though functions in cell(excel) works well, similar thing happened from above case when I try to execute macro. Or also similar error occurs when you are using function/arg name reserved by excel.

@vineethbabuR
Copy link
Author

hi,

that works, thank you for your support

vineeth

@fzumstein
Copy link
Member

Which version of Excel are you using, @vineethbabu4424 ? That error should be shown explicitly.

@vineethbabuR
Copy link
Author

i'm using Excel 2013 pro plus 32 bit

vineeth

@fzumstein
Copy link
Member

were you ever able to make it work?

@ilrico
Copy link

ilrico commented Feb 14, 2017

I had this message for various reasons:

  • check as stated here that your Trust center policies are ok. For me checking "Trust access to the VBA object model" usually solves the issue
  • check that your python functions/subs do not interfere with Excel reserved keywords in the signature (for instance def my_function(id=None, date=None) would fail since date is XL keyword. def my_function(id=None, dt=None) would be ok...)

@fzumstein
Copy link
Member

Closing this issue as I assume one of the suggestion by ilrico solved it. Feel free to reopen.

@SvenneRag
Copy link

SvenneRag commented Feb 20, 2019

Hi

I experience this problem when I add a controlformat object (a dropdown box) in my code and I reference that in my py-code. Example:

testDropDown = xw.Book('LineLimitViewer.xlsm').sheets("Front").api.Shapes("TestDropDown").ControlFormat

Do you have an example (or reference to your course material ;-)) which can guide me?

(Before I add the reference to the dropdown there is no problems)

Thx in advance

@lucaspenna00
Copy link

Please check trust access to the VBA project object model option (File > Options > Trust Center > Trust Center Settings > Macro Settings). In my case, even though functions in cell(excel) works well, similar thing happened from above case when I try to execute macro. Or also similar error occurs when you are using function/arg name reserved by excel.

I had the same issue. I used an argument called "date" in my UDF function. I suppose it's a reserved name by Excel. I changed the argument name and it worked. Thks a lot.

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

7 participants