0

I am calling a python script from VBA with the following:

Sub python_call()
Application.COMAddIns("DataNitro.DataNitro").Object.RunScript ("test.py")
'do some other stuff
End Sub

test.py takes a while to run so I want VBA to wait before running the remaining code. Is there a way to do that other than Application.Wait?

ayhan
  • 70,170
  • 20
  • 182
  • 203

1 Answers1

1

Can you call your VBA code from DataNitro, instead of the other way around? That'll execute synchronously.

Ben Lerner
  • 1,318
  • 9
  • 12
  • It is assigned to a button. I don't know if I can directly call Python by clicking on a button. – ayhan Oct 19 '15 at 22:02
  • 1
    It's a little roundabout, but here's how to do it: * put all of your functionality in a python script. * assign the button to a macro. Have that macro make one call, which calls your script. * put any other VBA functionality in a different macro that the script can call. – Ben Lerner Oct 22 '15 at 02:48
  • Works for me. Thank you. – ayhan Oct 22 '15 at 10:34