我可以设置键盘快捷键来运行DataNitro脚本吗? [英] Can I set up a keyboard shortcut to run a DataNitro script?

查看:136
本文介绍了我可以设置键盘快捷键来运行DataNitro脚本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用键盘快捷键在excel中运行VBA脚本,因此我可以将python代码打包为用户定义的函数,然后通过VBA调用它,但这并不雅致.

I know that I can run a VBA script in excel with a keyboard shortcut so I could package my python code as a user defined function and then call it through VBA but that is inelegant.

有更好的方法吗?

推荐答案

最好的方法是使用VBA调用Python脚本,而不是用户定义的函数.您可以使用以下代码来做到这一点:

The best way is to use VBA to call a Python script, rather than a user-defined function. You can do that with this code:

Sub call_DN()
    Application.COMAddIns("DataNitro.DataNitro").Object.RunScript ("test.py")
End Sub

与将代码打包为UDF相比,它提供了更多的灵活性.通过VBA仍然不是理想的选择,但是目前没有其他选择.

That gives you more flexibility than packaging the code as a UDF. It's still not ideal to go through VBA, but there's no other option right now.

[来源:我是DataNitro开发人员之一]

[Source: I'm one of the DataNitro developers]

这篇关于我可以设置键盘快捷键来运行DataNitro脚本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆