Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default use a macro to "Save As" to a generic desktop

I have a program that uses the SaveAs feature. However, the program is going
to be used my many users and I wanted to automate the process and have the
sheet save to the desktop. My problem is that the user id which is apart of
the address changes for each person. Is there a way to just save the file to
the desktop and not worry about the rest of the address? Here is my code....

ans = MsgBox("Save file as " & sFilename)
If ans = vbOK Then
ActiveWorkbook.SaveAs "C:\Documents and Settings\????????\Desktop" &
sFilename '
End If


Thanks,
Kyle
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default use a macro to "Save As" to a generic desktop

Kyle,

Here is one method to find the path to the logged on user's desktop.

______________________

Const Desktop = &H10&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(Desktop)
strDeskPath = objFolder.Self.Path
MsgBox strDeskPath

_______________________

Steve



"kyle" wrote in message
...
I have a program that uses the SaveAs feature. However, the program is
going
to be used my many users and I wanted to automate the process and have the
sheet save to the desktop. My problem is that the user id which is apart
of
the address changes for each person. Is there a way to just save the file
to
the desktop and not worry about the rest of the address? Here is my
code....

ans = MsgBox("Save file as " & sFilename)
If ans = vbOK Then
ActiveWorkbook.SaveAs "C:\Documents and Settings\????????\Desktop" &
sFilename '
End If


Thanks,
Kyle



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default use a macro to "Save As" to a generic desktop

The desktop is one of the special folders:

http://support.microsoft.com/default...b;en-us;252652
HOWTO: Use the SHGetFolderPath Function from Visual Basic

http://msdn.microsoft.com/library/de...nums/csidl.asp


or you can use the windows scripting host:


Create a link to the Windows Scripting Host Runtime libary
C:\WINDOWS\SYSTEM\WSHOM.OCX


Name is: IWshRuntimeLibrary


In Tools=References in the VBE it will be listed as: Windows Scripting Host
Object Model or something similar.


You can use this to get your desktop location:


Sub Tester15()


Dim wsh As New IWshShell_Class
Dim DesktopPath As String
DesktopPath = wsh.SpecialFolders.Item("Desktop")
msgbox DeskTopPath
end Sub


or without setting the reference


Sub Tester16()
Dim wsh As Object
Dim DesktopPath As String
set wsh = CreateObject("wscript.shell")
DesktopPath = wsh.SpecialFolders.Item("Desktop")
msgbox DeskTopPath
end Sub


--
Regards,
Tom Ogilvy




"kyle" wrote:

I have a program that uses the SaveAs feature. However, the program is going
to be used my many users and I wanted to automate the process and have the
sheet save to the desktop. My problem is that the user id which is apart of
the address changes for each person. Is there a way to just save the file to
the desktop and not worry about the rest of the address? Here is my code....

ans = MsgBox("Save file as " & sFilename)
If ans = vbOK Then
ActiveWorkbook.SaveAs "C:\Documents and Settings\????????\Desktop" &
sFilename '
End If


Thanks,
Kyle

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
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
"CELL("FILENAME") NOT UPDATE AFTER "SAVE AS" ACTION yossie6 Excel Discussion (Misc queries) 1 June 16th 08 12:16 PM
"Save" and "Save As" options greyed out - "Save as Webpage" option Bill Excel Discussion (Misc queries) 0 January 16th 07 04:47 PM
save and restore "Workbook Menu Bar" & "Cell" menus Jeff Higgins Excel Programming 2 February 14th 05 01:33 AM
Is there a "generic" Error Handling method Brad K. Excel Programming 1 January 27th 05 04:41 AM


All times are GMT +1. The time now is 04:12 AM.

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"