BOHICA needs help!

  • Thread starter Thread starter BOHICA
  • Start date Start date
B

BOHICA

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
 
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\Explorer\Shell Folders
....retrieve the string value "Desktop".
 
Bohica

the reply from MDW to your earlier post:

MDW said:
This should return the location of the desktop. I use it in VBScript, I
don't know what modifications (if any) you would need to make it work in
Excel.
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")

Regards

Trevor
 
WOOOHOOO! It works! Thanks goes out to you two brainiacs. Thank you
kindly for the help. Oh, and no I am not the same BOHICA from the
girly tagboards, as the only skirt I wear is my kilt.
 
WOOOHOOO! It works! Thanks goes out to you two brainiacs. Thank you
kindly for the help. Oh, and no I am not the same BOHICA from the
girly tagboards, as the only skirt I wear is my kilt.

Girly is a *comic strip*. <g>
--
auric "underscore" "underscore" "at" hotmail "dot" com
*****
We should be watching each other's backs, instead of watching our own
backs against each other.
-- SickRick
 
Back
Top