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

Importing several modules #991

Closed
alassauzet opened this Issue Nov 14, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@alassauzet

alassauzet commented Nov 14, 2018

OS (e.g. Windows 10 or macOS Sierra)

Windows 10

Versions of xlwings, Excel and Python (e.g. 0.11.8, Office 365, Python 3.7)

The last one (0.14.1) - Excel 16.0

Describe your issue (incl. Traceback!)

Hi guys,

When importing two modules, I have an « Excel automation error 440 », while it perfectly works when I import each one separately. And I use « ; » as explained in the doc to import them simultaneously in the field « UDF_MODULES » (confirmed in the conf file). Any idea ?

Thanks for your help,
Alix

@fzumstein fzumstein added the bug label Nov 16, 2018

@fzumstein

This comment has been minimized.

Member

fzumstein commented Nov 16, 2018

this error was introduced in v0.12. For now you can work around it by hacking the xlwings_udfs VBA module and remove the duplicate line

#Const App = "Microsoft Excel" 'Adjust when using outside of Excel

@fzumstein fzumstein added this to the 0.14.2 milestone Nov 16, 2018

@alassauzet

This comment has been minimized.

alassauzet commented Nov 16, 2018

Indeed, this makes it working. If I'm right, this should be fixed inside the function generate_vba_wrapper

xlwings/xlwings/udfs.py

Lines 299 to 307 in 98a0a6b

def generate_vba_wrapper(module_name, module, f):
vba = VBAWriter(f)
vba.writeln('Attribute VB_Name = "xlwings_udfs"')
vba.writeln("'Autogenerated code by xlwings - changes will be lost with next import!")
vba.writeln("""#Const App = "Microsoft Excel" 'Adjust when using outside of Excel""")

which is called for each imported module

xlwings/xlwings/udfs.py

Lines 414 to 416 in 98a0a6b

for module_name in module_names:
module = get_udf_module(module_name)
generate_vba_wrapper(module_name, module, tf.file)

Thanks again
Alix

@fzumstein fzumstein closed this in f6b9812 Nov 17, 2018

fzumstein added a commit that referenced this issue Nov 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment