Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Help Requires | Excel Discussion (Misc queries) | |||
novice requires help with vlook up | Excel Discussion (Misc queries) | |||
Function (array argument, range argument, string argument) vba | Excel Programming | |||
Wshshell / VB direction question | Excel Programming | |||
Argument can be a variant or an object | Excel Programming |