LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default difficulties using vba to save to the desktop

I've got a quirky problem. The network admin folks here at my office have a
bit of a strange naming convention for users. If you start as a part timer
you get a username that looks something like pt[loc][initials] so for someone
who is named John H. Smith starting part time at location number 04, his
login would be pt04jhs. The trouble is that if John switches to full time
his username changes to ft04jhs but his userprofile still points to the
directory C:\documents and settings\pt04jhs\. I want to use vba to export
(copy) a sheet from the workbook I'm in to a new workbook, save that workbook
to the desktop, and close that workbook without prompting the user.
(Incidentally, the rest of the naming convention for the file relies on a
combo box on the main menu (frmMainMenu) form called cmbSelectDivision, just
in case you're wondering why that's in there.) Here's my code right now:

dim NameThatExport as string
NameThatExport = "Division" +
frmMainMenu.cmbSelectDivision.Value _
+ ".xls"
Sheets("MyList").Select
Sheets("MyList").Copy
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\" + Environ("username") _
+ "\Desktop\" + NameThatExport, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False _
Windows(fileNm).Activate
Application.CutCopyMode = False
ActiveWorkbook.Close False


The code works well for users who started full time and remained full time
and for users who started part time and remained part time but for those who
started part time and switched to full time they get no autonaming. Is there
a way to use code to find the desktop other than the way I tried above?
Thanks for your help!
 
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
Desktop Save Question Jenny B. Excel Discussion (Misc queries) 7 March 26th 08 01:49 AM
Automatically Save a file on the Desktop ToyFixer Excel Programming 3 October 22nd 07 02:31 PM
Save to default desktop Mark Excel Discussion (Misc queries) 7 August 14th 05 01:04 PM
Save .xls as .txt In DeskTop Antonyo[_2_] Excel Programming 3 July 18th 05 01:52 PM
How do I save to the desktop across OS's? Greg Little Excel Programming 2 December 14th 04 10:40 PM


All times are GMT +1. The time now is 01:29 PM.

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

About Us

"It's about Microsoft Excel"