wscript & shell no longer works in excel 365

storm8

Active Member
Joined
Apr 7, 2010
Messages
327
I've been calling external code scripts (python in my case), with

VBA Code:
Private Function runOne(path) As Boolean
    Dim wsh As Object
    Dim d
    Set wsh = VBA.CreateObject("WScript.Shell")
    Dim waitOnReturn As Boolean: waitOnReturn = True
    Dim windowStyle As Integer: windowStyle = 1
    Dim s As String
    s = "python " & Chr(34) & path & Chr(34)
    d = wsh.Run(s, windowStyle, waitOnReturn)
    DoEvents
    If d = 0 Then runOne = True
End Function

but since one of the latest updates to Office 365 this no longer works. cmd window will briefly show up but is killed immediately without the code executing. Running external scripts is definitely a security issue but I was not able to figure out how to bypass security checks and run scripts anyway. Adding documents parent folder to truested locations does not help.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
finally found a solution!
this works

Shell("notepad.exe") works anyway, but shell, unlike wscript does not allow to waint untill the code finishes. The solution in above link makes excel wait until the shell finishes.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top