1

In ThisWorkbook Excel Object I have the following two subroutines:

Private Sub Workbook_Open()
    MsgBox "Hello World"

    Call call_DN

End Sub

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

When I open the workbook I see the "Hello World" message box and then the "called sub" message box but the python script does not execute.

However, when I then manually run Workbook_Open() the python script does execute properly.

Why is the python script not executing upon application startup?

No error messages are being thrown - it seems that the .runscript command is just being ignored.

Community
  • 1
  • 1
DFT
  • 65
  • 4
  • What does "test.py" do? – Ben Lerner Mar 02 '15 at 04:41
  • It is a single line....Cell("A9").value = 1 – DFT Mar 02 '15 at 13:29
  • The more general problem is that while windows task scheduler can call a python script, Datanitro must be initiated from within an open excel workbook. Accordingly, the only method I am aware of to make use of Datanitro via windows task scheduler is to have task scheduler open the excel file and then call the datanitro script from the Workbook_Open() subroutine. – DFT Mar 02 '15 at 20:55

1 Answers1

1

DataNitro has an autostart option for calling a script on workbook start. Please use that rather than VBA's workbook open hook.

(The workbook open hook should work in theory, but it looks like it doesn't.)

Ben Lerner
  • 1,318
  • 9
  • 12