ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA code for: Saving to desktop? (https://www.excelbanter.com/excel-programming/290027-vba-code-saving-desktop.html)

jasonsweeney[_37_]

VBA code for: Saving to desktop?
 
My spreadsheet will be distributed to many different users.

I need code to force the saving of a file on the desktop of th
computer using the xls. spreadsheet.

Of course, the Desktop is under My Documents/[name of re
user]/Desktop

DOes anybody know how to code the path to always save on any computer'
desktop, whether personal computer, networked, etc.???

(Basically, I have created a data file based on the user's entires i
the main spreadsheet that needs to be saved to the desktop of th
user's computer because that person has to attach that file and emai
it back to me....and I want the file easy to find when they ar
attaching it to an email

--
Message posted from http://www.ExcelForum.com


Robin Hammond[_2_]

VBA code for: Saving to desktop?
 
This seems to work on my machine but might need some testing

Sub SaveToDesktop()
Dim strPath As String
strPath = Environ("HomeDrive") & Environ("HomePath") & "\Desktop\Test.xls"
ActiveWorkbook.SaveAs strPath
End Sub

Then again, why don't you include the code to email the sheet back to you in
the sheet you are distributing. If everyone is on Outlook it is not that
difficult. Have a search on google under "sending email outlook" and you'll
find some ways to do it.

Robin Hammond
www.enhanceddatasystems.com

"jasonsweeney " wrote in
message ...
My spreadsheet will be distributed to many different users.

I need code to force the saving of a file on the desktop of the
computer using the xls. spreadsheet.

Of course, the Desktop is under My Documents/[name of reg
user]/Desktop

DOes anybody know how to code the path to always save on any computer's
desktop, whether personal computer, networked, etc.???

(Basically, I have created a data file based on the user's entires in
the main spreadsheet that needs to be saved to the desktop of the
user's computer because that person has to attach that file and email
it back to me....and I want the file easy to find when they are
attaching it to an email)


---
Message posted from http://www.ExcelForum.com/




Shatin

VBA code for: Saving to desktop?
 
Following is based on code posted in this newsgroup not so long ago
and works well for me:

ActiveWorkbook.SaveAs _
Filename:=Environ("USERPROFILE") & "\Desktop\" & filename, _
FileFormat:=xlNormal


All times are GMT +1. The time now is 06:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com