Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 94
Default Desktop Save Question

Hi All,

I'm setting up a macro that will be used by multiple users. One of the
pieces consists of placing a copy of the form to the users desktop. My
question is - how can I set up the desktop address to save to random users
vs. the standard single user address? Right now the below is just referring
just one person (MyName) and I need it to be generic and encompass whoever is
using the application and not be specific.

Thank you in advance - Jenny B.

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = "C:\Documents and Settings\MyName\Desktop"
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call CLEAR
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Desktop Save Question

Place at the top of you module
Private Declare Function GetUserName Lib _
"advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
I use this function and you could pass to your mypath
mypath = "C:\Documents and Settings\" & UserNameWindows & "\Desktop"
Private Function UserNameWindows() As String
Dim lngLen As Long
Dim strBuffer As String
Const dhcMaxUserName = 255
strBuffer = Space(dhcMaxUserName)
lngLen = dhcMaxUserName
If CBool(GetUserName(strBuffer, lngLen)) Then
UserNameWindows = Left$(strBuffer, lngLen - 1)
Else
UserNameWindows = ""
End If
End Function

"Jenny B." wrote:

Hi All,

I'm setting up a macro that will be used by multiple users. One of the
pieces consists of placing a copy of the form to the users desktop. My
question is - how can I set up the desktop address to save to random users
vs. the standard single user address? Right now the below is just referring
just one person (MyName) and I need it to be generic and encompass whoever is
using the application and not be specific.

Thank you in advance - Jenny B.

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = "C:\Documents and Settings\MyName\Desktop"
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call CLEAR
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Desktop Save Question

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = CreateObject("WScript.Shell").SpecialFolders(10)
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs Filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call Clear
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jenny B." wrote in message
...
Hi All,

I'm setting up a macro that will be used by multiple users. One of the
pieces consists of placing a copy of the form to the users desktop. My
question is - how can I set up the desktop address to save to random users
vs. the standard single user address? Right now the below is just
referring
just one person (MyName) and I need it to be generic and encompass whoever
is
using the application and not be specific.

Thank you in advance - Jenny B.

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = "C:\Documents and Settings\MyName\Desktop"
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call CLEAR
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 94
Default Thanks to both Bob and Mike

Thank you both. Both ideas will work great and I really appreciate all of
your help.

Have a great day - Jenny B.

"Bob Phillips" wrote:

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = CreateObject("WScript.Shell").SpecialFolders(10)
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs Filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call Clear
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jenny B." wrote in message
...
Hi All,

I'm setting up a macro that will be used by multiple users. One of the
pieces consists of placing a copy of the form to the users desktop. My
question is - how can I set up the desktop address to save to random users
vs. the standard single user address? Right now the below is just
referring
just one person (MyName) and I need it to be generic and encompass whoever
is
using the application and not be specific.

Thank you in advance - Jenny B.

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = "C:\Documents and Settings\MyName\Desktop"
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call CLEAR
End Sub





  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 94
Default Desktop Save Question

Good Morning

One more quick question. This code places it one step outside of the
Desktop folder (see the below path). Is there any way to direct it inside
the Desktop folder?

Thanks again - Jenny B.

C:\Documents and Settings\MyName

"Bob Phillips" wrote:

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = CreateObject("WScript.Shell").SpecialFolders(10)
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs Filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call Clear
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jenny B." wrote in message
...
Hi All,

I'm setting up a macro that will be used by multiple users. One of the
pieces consists of placing a copy of the form to the users desktop. My
question is - how can I set up the desktop address to save to random users
vs. the standard single user address? Right now the below is just
referring
just one person (MyName) and I need it to be generic and encompass whoever
is
using the application and not be specific.

Thank you in advance - Jenny B.

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = "C:\Documents and Settings\MyName\Desktop"
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call CLEAR
End Sub







  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Desktop Save Question

That give me

C:\Documents and Settings\Bob\Desktop

Try entering this

?CreateObject("WScript.Shell").SpecialFolders(10)

in the Immediate window in the VBIDE, maybe changing the value if it isn't
correct.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jenny B." wrote in message
...
Good Morning

One more quick question. This code places it one step outside of the
Desktop folder (see the below path). Is there any way to direct it inside
the Desktop folder?

Thanks again - Jenny B.

C:\Documents and Settings\MyName

"Bob Phillips" wrote:

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = CreateObject("WScript.Shell").SpecialFolders(10)
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs Filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call Clear
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Jenny B." wrote in message
...
Hi All,

I'm setting up a macro that will be used by multiple users. One of the
pieces consists of placing a copy of the form to the users desktop. My
question is - how can I set up the desktop address to save to random
users
vs. the standard single user address? Right now the below is just
referring
just one person (MyName) and I need it to be generic and encompass
whoever
is
using the application and not be specific.

Thank you in advance - Jenny B.

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = "C:\Documents and Settings\MyName\Desktop"
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call CLEAR
End Sub







  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Desktop Save Question

Maybe using:

mypath = CreateObject("WScript.Shell").SpecialFolders("Desk Top")

Would work better for you.

Jenny B. wrote:

Good Morning

One more quick question. This code places it one step outside of the
Desktop folder (see the below path). Is there any way to direct it inside
the Desktop folder?

Thanks again - Jenny B.

C:\Documents and Settings\MyName

"Bob Phillips" wrote:

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = CreateObject("WScript.Shell").SpecialFolders(10)
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs Filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call Clear
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jenny B." wrote in message
...
Hi All,

I'm setting up a macro that will be used by multiple users. One of the
pieces consists of placing a copy of the form to the users desktop. My
question is - how can I set up the desktop address to save to random users
vs. the standard single user address? Right now the below is just
referring
just one person (MyName) and I need it to be generic and encompass whoever
is
using the application and not be specific.

Thank you in advance - Jenny B.

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = "C:\Documents and Settings\MyName\Desktop"
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call CLEAR
End Sub






--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 94
Default Desktop Save Question

Thank you - it's working just great now!

"Dave Peterson" wrote:

Maybe using:

mypath = CreateObject("WScript.Shell").SpecialFolders("Desk Top")

Would work better for you.

Jenny B. wrote:

Good Morning

One more quick question. This code places it one step outside of the
Desktop folder (see the below path). Is there any way to direct it inside
the Desktop folder?

Thanks again - Jenny B.

C:\Documents and Settings\MyName

"Bob Phillips" wrote:

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = CreateObject("WScript.Shell").SpecialFolders(10)
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs Filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call Clear
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jenny B." wrote in message
...
Hi All,

I'm setting up a macro that will be used by multiple users. One of the
pieces consists of placing a copy of the form to the users desktop. My
question is - how can I set up the desktop address to save to random users
vs. the standard single user address? Right now the below is just
referring
just one person (MyName) and I need it to be generic and encompass whoever
is
using the application and not be specific.

Thank you in advance - Jenny B.

Sub DesktopSave()

Dim mypath As String
Dim nrng As Range
Dim fname As String
Set nrng = Range("H5")
ActiveSheet.Copy
mypath = "C:\Documents and Settings\MyName\Desktop"
fname = nrng.Value & ".xls"
ActiveWorkbook.SaveAs filename:= _
mypath & fname, FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Call TransfertoLog
Call CLEAR
End Sub






--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
EXCEL FILES SAVED TO DESKTOP WILL NOT OPEN FROM DESKTOP randy111 Excel Discussion (Misc queries) 3 January 13th 08 11:38 PM
Another Save Question Sandy Excel Worksheet Functions 1 May 19th 07 08:46 PM
Macro - Save file in Desktop Dileep Chandran Excel Worksheet Functions 2 December 1st 06 09:37 AM
Save to default desktop Mark Excel Discussion (Misc queries) 7 August 14th 05 02:04 PM
Save as not working for laptop to desktop Adra Excel Worksheet Functions 3 March 29th 05 11:55 PM


All times are GMT +1. The time now is 12:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"