Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Desktop path?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Desktop path?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default Desktop path?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Desktop path?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Desktop path?

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
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
Remove end folder from path found with ThisWorkbook.Path command ? dim Excel Programming 9 April 23rd 08 06:04 AM
EXCEL FILES SAVED TO DESKTOP WILL NOT OPEN FROM DESKTOP randy111 Excel Discussion (Misc queries) 3 January 13th 08 10:38 PM
How to path to user's desktop 1scant[_8_] Excel Programming 2 June 16th 06 03:52 PM
hyperlink navigation path path wrong in Excel 2003 CE Admin Excel Discussion (Misc queries) 5 January 7th 06 07:47 PM
how to change absolute path to relative path hwijgerse Excel Worksheet Functions 0 November 25th 05 07:18 AM


All times are GMT +1. The time now is 04:15 PM.

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

About Us

"It's about Microsoft Excel"