Let's say I have a powershell script sorta like this:
'Hey'
Which I want to call in VBA sorta like this:
Sub CallPowerShell()
Call Shell("powershell.exe -ExecutionPolicy Bypass C:\Users\chm\Documents\5.ps1")
End Sub
I know this works as a console window briefly pops up with the word 'Hey' in it. What I really want however, is to use this string in my VBA code.
Is there a simple way how to get a return value from a powershell script through VBA?
Ideally it would be something like this:
Dim x As String
Sub CallPowerShell()
x = Shell("powershell.exe -ExecutionPolicy Bypass C:\Users\chm\Documents\5.ps1")
End Sub
But that just sets x to seemingly random numbers like 70640 or 30960.
I could have the powershell script write the value I want to a file and then read the file in VBA but it'd be really nice if I could skip that so I figured I'd ask here.