ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   IWshRuntimeLibrary.WshShell.SpecialFolders requires a variant argument (https://www.excelbanter.com/excel-programming/376275-iwshruntimelibrary-wshshell-specialfolders-requires-variant-argument.html)

ion

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


NickHK

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




ion

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




All times are GMT +1. The time now is 04:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com