Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have Excel create a report (a .TXT-file) via VBA, and that part works fine
:-) But now I would like Excel to automatically save this report on the users desktop for easy access, everytime the user runs the macro. But being in a multinational company the name and path of the users desktop can be very different! I've tried to see if there's an ENV-variable, telling me the current desktop-path, but I couldn't find it, so... ....is there a way to find the current desktop path in VBA??? TIA, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim myPath As String
myPath = CreateObject("WScript.Shell").SpecialFolders("Desk Top") MsgBox myPath "Charlotte E." wrote: I have Excel create a report (a .TXT-file) via VBA, and that part works fine :-) But now I would like Excel to automatically save this report on the users desktop for easy access, everytime the user runs the macro. But being in a multinational company the name and path of the users desktop can be very different! I've tried to see if there's an ENV-variable, telling me the current desktop-path, but I couldn't find it, so... ...is there a way to find the current desktop path in VBA??? TIA, -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if you want to try the environment variable route, this may work. works in
english versions xp and vista. i think some have reported issues, but i've never seen them. environ("USERPROFILE") & "\Desktop\" -- Gary Excel 2003 "Charlotte E." <@ wrote in message ... I have Excel create a report (a .TXT-file) via VBA, and that part works fine :-) But now I would like Excel to automatically save this report on the users desktop for easy access, everytime the user runs the macro. But being in a multinational company the name and path of the users desktop can be very different! I've tried to see if there's an ENV-variable, telling me the current desktop-path, but I couldn't find it, so... ...is there a way to find the current desktop path in VBA??? TIA, |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
See http://www.cpearson.com/Excel/SpecialFolders.aspx for VBA code that will
return the full path of any of the Windows User's special folders (e.g., Desktop, Temp, My Documents, etc). -- Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) "Gary Keramidas" wrote in message ... if you want to try the environment variable route, this may work. works in english versions xp and vista. i think some have reported issues, but i've never seen them. environ("USERPROFILE") & "\Desktop\" -- Gary Excel 2003 "Charlotte E." <@ wrote in message ... I have Excel create a report (a .TXT-file) via VBA, and that part works fine :-) But now I would like Excel to automatically save this report on the users desktop for easy access, everytime the user runs the macro. But being in a multinational company the name and path of the users desktop can be very different! I've tried to see if there's an ENV-variable, telling me the current desktop-path, but I couldn't find it, so... ...is there a way to find the current desktop path in VBA??? TIA, |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Works - thanks :-)
Dave Peterson wrote: Dim myPath As String myPath = CreateObject("WScript.Shell").SpecialFolders("Desk Top") MsgBox myPath "Charlotte E." wrote: I have Excel create a report (a .TXT-file) via VBA, and that part works fine :-) But now I would like Excel to automatically save this report on the users desktop for easy access, everytime the user runs the macro. But being in a multinational company the name and path of the users desktop can be very different! I've tried to see if there's an ENV-variable, telling me the current desktop-path, but I couldn't find it, so... ...is there a way to find the current desktop path in VBA??? TIA, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Remove end folder from path found with ThisWorkbook.Path command ? | Excel Programming | |||
EXCEL FILES SAVED TO DESKTOP WILL NOT OPEN FROM DESKTOP | Excel Discussion (Misc queries) | |||
How to path to user's desktop | Excel Programming | |||
hyperlink navigation path path wrong in Excel 2003 | Excel Discussion (Misc queries) | |||
how to change absolute path to relative path | Excel Worksheet Functions |