desktop path (again, sigh...)

madEG

Registered User.
Local time
Today, 12:26
Joined
Jan 26, 2007
Messages
307
The first works fine, and stores the path - but I would prefer to not use the windows scripting host as I don't know what script blocking stuff the security in a client's place may be implemented...

strPath = CreateObject("WScript.Shell").SpecialFolders("Desktop")

vs:

strPath = fso.GetSpecialFolder(DesktopDirectory)

What is wrong with the bottom line? I keep getting, merely "C:\windows" rather than the user's path to desktop...?
 
Why not reference the desktop directory directly?

c:\documents and settings\%username%\Desktop

Or you can use this in Access:

strUserName = Environ("UserName")

strPath = "C:\documents and settings\" & strUserName & "\Desktop"
 
While that is a sound idea, I worry about users who have changed their usernames and now no longer have a desktop path that matches their updated username. (e.g. This sometimes happened here when women get married and change their last name, or hyphenate/concat their lastname with a new one...)

I just don't think I can 100% safely rely on that approach.
 
Hello Bob,

I'll take a look through this. Never messed with APIs much...

Question though... what do you mean by "set(ting) references"? -- Maybe there is a easier way to do this that I am overlooking...

Thanks!
 
Question though... what do you mean by "set(ting) references"? -- Maybe there is a easier way to do this that I am overlooking...

Thanks!
When using the Windows Scripting Host, or anything else with EARLY BINDING (I didn't say you were using it, as the code you initially provided was LATE BINDING and didn't need the reference), you need to set a reference to it via Tools > References in the VBA IDE window. Setting references can lead to issues on other machines and all (it can be hit or miss sometimes, depending on what you are using), so if you don't have to set a reference in advance like that it tends to work out better.

Using API's will get you around a host of issues as it accesses the Operating System at a lower level and bypasses some of the "translation layers" that other methods require.
 
While that is a sound idea, I worry about users who have changed their usernames and now no longer have a desktop path that matches their updated username. (e.g. This sometimes happened here when women get married and change their last name, or hyphenate/concat their lastname with a new one...)

I just don't think I can 100% safely rely on that approach.

A persons username should always match the username path on the machine. If it does not, then that's something your IT department should fix.
 

Users who are viewing this thread

Back
Top Bottom