Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
WScript object not found (???)
How about
Sub aaaa_testscript() Set WshShell = CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("VOLATILE") Debug.Print WshSysEnv("LOGONSERVER") End Sub or Sub aaaa_testscript() Set WshShell = VBA.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("VOLATILE") Debug.Print WshSysEnv("LOGONSERVER") End Sub remove the Wscript from CreateObject. Regards, Tom Ogilvy "Randall Arnold" wrote in message ... I am using the following code in Windows Scripting Host (wsh) macro: Set WshShell = WScript.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("VOLATILE") Wscript.Echo WshSysEnv("LOGONSERVER") This displays the name of the DNS logon server. It works fine as a standalone script. Now, I need this to run in an Excel 2003 VBA module so I modified the code as follows: Set WshShell = WScript.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("VOLATILE") debug.print WshSysEnv("LOGONSERVER") After running the macro, I received an "Object not found" error. According to WSH docs, no reference is needed, but I added one anyway and re-ran the macro-- same result. Excel VBA claims that the WScript object is not instantiated, it seems. However, WSH starts as a part of the OS so it *should* be there. The fact that the script runs fine but the VBA version doesn't has me mystified. I'm wondering if it's a bug in the Excel 2003 beta. Anyone have any clues? Randall Arnold |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
WScript object not found (???)
D'oh!
Thanks Tom. Man, I'm an idiot. I should have known that! -Randy "Tom Ogilvy" wrote in message ... How about Sub aaaa_testscript() Set WshShell = CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("VOLATILE") Debug.Print WshSysEnv("LOGONSERVER") End Sub or Sub aaaa_testscript() Set WshShell = VBA.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("VOLATILE") Debug.Print WshSysEnv("LOGONSERVER") End Sub remove the Wscript from CreateObject. Regards, Tom Ogilvy "Randall Arnold" wrote in message ... I am using the following code in Windows Scripting Host (wsh) macro: Set WshShell = WScript.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("VOLATILE") Wscript.Echo WshSysEnv("LOGONSERVER") This displays the name of the DNS logon server. It works fine as a standalone script. Now, I need this to run in an Excel 2003 VBA module so I modified the code as follows: Set WshShell = WScript.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("VOLATILE") debug.print WshSysEnv("LOGONSERVER") After running the macro, I received an "Object not found" error. According to WSH docs, no reference is needed, but I added one anyway and re-ran the macro-- same result. Excel VBA claims that the WScript object is not instantiated, it seems. However, WSH starts as a part of the OS so it *should* be there. The fact that the script runs fine but the VBA version doesn't has me mystified. I'm wondering if it's a bug in the Excel 2003 beta. Anyone have any clues? Randall Arnold |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2 Label Options - Forms Object vs Control Box Object | Excel Discussion (Misc queries) | |||
Excel found unreadable content in 'stock.chart.object.xlsm' | Charts and Charting in Excel | |||
Object required??? What object? | Excel Discussion (Misc queries) | |||
Object Variable Not Set Error on Selection object | Excel Worksheet Functions | |||
IF NOT FOUND | Excel Worksheet Functions |