Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ion ion is offline
external usenet poster
 
Posts: 12
Default IWshRuntimeLibrary.WshShell.SpecialFolders requires a variant argument

This was hard to debug.
Dim bulb as new IWshRuntimeLibrary.WshShell
dim str as string, var as variant
str = "MyDocuments"
var = str
Debug.print bulb.SpecialFolders(str) ' prints the all users desktop
Debug.print bulb.SpecialFolders(var) ' prints the My Documents folder

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default IWshRuntimeLibrary.WshShell.SpecialFolders requires a variant argument

Any reason you are using a COM wrapper to .Net framework functions ?

Otherwise, use the normal Windows API :
http://vbnet.mvps.org/code/browse/csidl.htm

Or depending what you need:
Environ("USERPROFILE")
Environ("HOMEPATH")
Environ("HOMEDRIVE")

NickHK

"ion" wrote in message
oups.com...
This was hard to debug.
Dim bulb as new IWshRuntimeLibrary.WshShell
dim str as string, var as variant
str = "MyDocuments"
var = str
Debug.print bulb.SpecialFolders(str) ' prints the all users desktop
Debug.print bulb.SpecialFolders(var) ' prints the My Documents folder



  #3   Report Post  
Posted to microsoft.public.excel.programming
ion ion is offline
external usenet poster
 
Posts: 12
Default IWshRuntimeLibrary.WshShell.SpecialFolders requires a variant argument

Nick,
I don't think this is handled by .NET. I'm in the vba Engine in
Excel! I can shut down the framework, and it works great.
If a path fails to resolve, I check if its first token is a special
folder name. That was my goal, and I was surprised that passing the
token as a string didn't give me the correct answer. It must be passed
as a variant.
Ion

NickHK wrote:
Any reason you are using a COM wrapper to .Net framework functions ?

Otherwise, use the normal Windows API :
http://vbnet.mvps.org/code/browse/csidl.htm

Or depending what you need:
Environ("USERPROFILE")
Environ("HOMEPATH")
Environ("HOMEDRIVE")

NickHK

"ion" wrote in message
oups.com...
This was hard to debug.
Dim bulb as new IWshRuntimeLibrary.WshShell
dim str as string, var as variant
str = "MyDocuments"
var = str
Debug.print bulb.SpecialFolders(str) ' prints the all users desktop
Debug.print bulb.SpecialFolders(var) ' prints the My Documents folder


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
Macro Help Requires Dan Wood Excel Discussion (Misc queries) 5 March 4th 10 01:16 PM
novice requires help with vlook up [email protected] Excel Discussion (Misc queries) 1 March 22nd 07 07:19 PM
Function (array argument, range argument, string argument) vba Witek[_2_] Excel Programming 3 April 24th 05 03:12 PM
Wshshell / VB direction question Steve[_58_] Excel Programming 3 May 24th 04 09:20 PM
Argument can be a variant or an object onedaywhen Excel Programming 1 September 25th 03 04:20 PM


All times are GMT +1. The time now is 05:06 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"