Save file to each users desktop? (1 Viewer)

option

Registered User.
Local time
Today, 12:04
Joined
Jul 3, 2008
Messages
143
Hey guys,

I'm trying to save a file to the desktop for all that use it. The problem is, since we're all on a network, and the path to each users desktop is going to be different (ex: C:\Documents and Settings\user\Desktop(where user is going to be different)). Is there a way to modify my code with a way to pick up the users path to their desktop? Or am I going to have to code it in?


Code:
Private Sub CommandButton2_Click()
Dim savename As String

savename = Range("e6").value 'This is the cell with the info I need in the file 'name

ActiveWorkbook.SaveAs "C:\workflow\" & Format(Date, "yyyymmdd") & "_" & savename & ".xls"

End Sub
The "C:\workflow\" needs to change to the desktop. Thanks guys!!
 

namliam

The Mailman - AWF VIP
Local time
Today, 18:04
Joined
Aug 11, 2003
Messages
11,695
Environ("Username") will give you their username which is your "missing link"

Happy hunting :)
 

chergh

blah
Local time
Today, 17:04
Joined
Jun 15, 2004
Messages
1,414
Code:
Private Declare Function GetUserName _
   Lib "advapi32.dll" Alias "GetUserNameA" _
   (ByVal lpBuffer as String, nSize as Long) _
   As Long   

Public Function UserName() as String

Dim sName as String * 256
Dim cChars as Long

cChars = 256

If GetUserName(sName, cChars) Then
   UserName = Left$(sName, cChars -1)
End If
End Function

Private Sub CommandButton2_Click()
Dim savename As String

savename = Range("e6").value 'This is the cell with the info I need in the file 'name

ActiveWorkbook.SaveAs "C:\Documents and Settings\" & username & "\Desktop\" & Format(Date, "yyyymmdd") & "_" & savename & ".xls"

End Sub
 

option

Registered User.
Local time
Today, 12:04
Joined
Jul 3, 2008
Messages
143
Environ worked! I've used that numerous times, why I didn't think of it...I'll never know!! haha, Thanks guys!
 
Local time
Today, 11:04
Joined
Mar 4, 2008
Messages
3,856
Not related...you realize that storing files on a desktop actually degrades Windows overall performance, right? Better to save a shortcut on the Desktop and the file somewhere in "My Documents".

Additionally, the naming scheme has changed in Vista so your code is likely to break when one of your users moves to Vista.
 

rainman89

I cant find the any key..
Local time
Today, 12:04
Joined
Feb 12, 2007
Messages
3,016
Not related...you realize that storing files on a desktop actually degrades Windows overall performance, right? Better to save a shortcut on the Desktop and the file somewhere in "My Documents".

Additionally, the naming scheme has changed in Vista so your code is likely to break when one of your users moves to Vista.

you dont say??? you mean having 500 documents on my desktop is slowing my computer down???:confused::confused::confused::eek::eek::eek:

i always love seeing that
 

namliam

The Mailman - AWF VIP
Local time
Today, 18:04
Joined
Aug 11, 2003
Messages
11,695
you dont say???
About a week ago...

My Customer:
I guess my 1.2 gig home grown amature over the top access database on my desktop is a problem???

Oh... yeah I do take 20 minutes to startup in the morning... what did you say? You can bring this down to 2 minutes? Great!!
Any my DB down to 20 meg?? Wow!!! You are a magician mr Mailman...

My toughts:
Yeah sure, just a matter of a compact ;)

10 minutes later:
Presto sir, your improved computer have fun.
Oh and by the way... it seems you have access to this and that database.

Customer:
Yeah I had a friend (who was fired months back) who granted me access.

My thoughts:
OK ? Guess I know why the guy got fired... This guy shouldnt have access to these databases... Could explain a data corruption or two we have been experiencing lately.

My Answer...
OK Cool... Have a nice day.

Back at the desk:
Kill user/pw

10 minutes later phone rings...
Customer: You fixed my computer, buy my DB dont work anymore :mad:
Me: Oh whats wrong??
Customer: It says unable to authenticate
Me: That means you dont have rights to the DB.
Let me check our systems.... What user did you have?
Customer: User? I dont know
Me: OK Let me check your credentials, No I cannot find your authorization to have access to this anywhere....
Do you have a copy??
Customer: Nevermind :(
 

option

Registered User.
Local time
Today, 12:04
Joined
Jul 3, 2008
Messages
143
Not related...you realize that storing files on a desktop actually degrades Windows overall performance, right? Better to save a shortcut on the Desktop and the file somewhere in "My Documents".

Additionally, the naming scheme has changed in Vista so your code is likely to break when one of your users moves to Vista.

A) The users desktops are locked down. They don't have access to ANY folders or shortcuts, hence saving on the desktop :)

B) Vista = for retards. We're not switch to Vista here aaaaaaaaaaaaaany time soon, but thanks!
 
Local time
Today, 11:04
Joined
Mar 4, 2008
Messages
3,856
B) Vista = for retards. We're not switch to Vista here aaaaaaaaaaaaaany time soon, but thanks!

LOL, that makes me a retard! But I understand your statement and won't take it as an insult (I think).

Vista is the suckiest OS I believe I've ever had to use. I've had nothing but problems, except when playing video games.

But the point I was trying to make is that newer OSs are changing the "location" of users files. Since Vista has done it, you can be assured that the next OS that MS offers that doesn't suck (may it come sooner than later) will have it that way, too.

Unfortunately, you can no longer buy a new PC without Vista. An enterprise can just re-image new PCs...home business users cannot.
 

option

Registered User.
Local time
Today, 12:04
Joined
Jul 3, 2008
Messages
143
Oh I hear you there! And that was not intended to be an insult, sorry about that :). The way I see it: if you didn't say it, someone browsing this thread may not have known it and never would have, had you not said it!
 

Users who are viewing this thread

Top Bottom