Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Label Options - Forms Object vs Control Box Object Awrex Excel Discussion (Misc queries) 3 July 17th 09 07:10 PM
Excel found unreadable content in 'stock.chart.object.xlsm' jcmjcm Charts and Charting in Excel 0 May 21st 09 09:14 PM
Object required??? What object? jlclyde Excel Discussion (Misc queries) 8 November 1st 08 01:21 AM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
IF NOT FOUND roy.okinawa Excel Worksheet Functions 5 November 17th 05 04:26 AM


All times are GMT +1. The time now is 01:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"