VBA code for: Saving to desktop?

  • Thread starter Thread starter jasonsweeney
  • Start date Start date
J

jasonsweeney

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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top