BOHICA needs help!
On 26 Feb 2004 12:24:02 -0800, BOHICA wrote:
Hello all! I had posted a message here, and I do not believe it was
answered. Maybe it fell through the cracks (very possible as there
are bunches of posts a day) or maybe it was deleted because someone
found the secret communist anti-France satanic message hidden
carefully within the subject title. Or maybe you people have answered
this same question about 500 times and didn't want to answer it a
501st time.
Well...sorry, but I fear I must bother you again. If I missed the
post and someone DID answer me, sorry, but I missed it.
My Question:
Does anyone know how I can get a spreadsheet to save to desktop
consistently on an NT based system where user name might be different?
If I do not put anyfile path in my macro, it saves it to the users
documents folder. is there a way i might be able to backstep to
desktop from there? or is there a way i can just say "userDesktop" or
something? Or will I need to somehow find the active username and add
it into a filename string like {"C:\Documents and Settings\" &
UserName & "\Desktop\" & DForm.DSave & ".xls"}? Thanks
(This isn't the same BOHICA from the Girly tagboard, is it?)
The easiest, but not always accurate, way is to use
Environ("USERPROFILE") - this returns the absolute path to the current
user's profile. For the desktop do this:
desk$ = Environ("USERPROFILE") & "\Desktop"
"MDW" gave an easier way to do this, in response to your previous post:
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
....but for this to work in Excel, you need to add a reference to the
"Windows Script Host Object Model" (in the VBA editor: Tools menu -
References) and then change the code to something like this:
Dim wsh As WshShell 'can't use WshShell as a var - it's a class
strDesktop = wsh.SpecialFolders("Desktop")
This assumes that Windows Scripting is installed, which is pretty safe,
unless you have users running Win95 without IE4+ installed. If you do,
just pull it straight from the registry:
HKCU\Software\Microsoft\Windows\CurrentVersion\Exp lorer\Shell Folders
....retrieve the string value "Desktop".
--
auric "underscore" "underscore" "at" hotmail "dot" com
*****
Things worth having are worth cheating for.
|