Pregunta

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.

Is there a better way to do this?

¿Fue útil?

Solución

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

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.

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top