TropicalFred
Technical User
I have a VBScript that runs fine when I save it as a .vbs file, but when I put it into an Excel VBA module and try to run it I get a VB "Object Required" error on the first line. What am I doing wrong?
VBS code:
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("System")
WScript.Echo objEnv("OS")
VBA Code:
Sub vbs_test1()
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("System")
WScript.Echo objEnv("OS")
End Sub
VBS code:
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("System")
WScript.Echo objEnv("OS")
VBA Code:
Sub vbs_test1()
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("System")
WScript.Echo objEnv("OS")
End Sub