Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VB Editor VBA Saving File to Desktop WinXP

Status
Not open for further replies.

dprayner

Programmer
Joined
Oct 14, 2002
Messages
140
Location
US
Hi Good people. I am on a network and I want to save a file to the Desktop C:\Documents and Settings\User\ Desktop\*.xls. The file saves correctly if I code my username. How do I code for any user on the network who may user the spreadsheet and save it to their desktop? Thank you, DAVE
 
First, I'd just like to point out for future reference that this topic really should have been posted in forum707, the VBA Visual Basic for Applications (Microsoft) Forum.

Try this:
Code:
MyVariable = Environ("USERNAME")
Then use the variable when saving like this:
Code:
activeworkbook.saveas "C:\Documents and Settings\" & MyVariable  &"\ Desktop\FileName.xls."

[tt]_____
[blue]-John[/blue]
[/tt][red]"I'm against picketing, but I don't know how to show it."[/red]
-Mitch Hedberg

Help us help you. Please read FAQ181-2886 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top