Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Point to My Docs in Win7/XP, Excel 03/07

Hi,
I have a file that's shared on multiple computers using different OS and
versions of Excel....
Windows 7, XP Pro, Excel 03 and Excel 07.

Is there a common function that can get the true location of the "My
Documents" folder for all the above combinations?

I guess I wouldn't need the actual folder name if there is a common alias I
could grab on to. It just has to be able to work if someone moved the "My
Documents" location to a non-default drive or folder.

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Point to My Docs in Win7/XP, Excel 03/07

You can usually get it from Environ variables:

Function MyDocumentsFolder() As String
MyDocumentsFolder = Environ("HomeDrive") & _
Environ("HomePath") & "\My Documents"
End Function

Or, to be safe in case those variables don't work, you can use the
GetSpecialFolders function I have at
http://www.cpearson.com/excel/SpecialFolders.aspx . On that page is a
downloadable module that has all the code you need. With that, you can
use

Function MyDocumentsFolder() As String
MyDocumentsFolder = GetSpecialFolder(CSIDL_PERSONAL)
End Function

This has the advantage that you aren't hard coding anything, which may
be important for supporting other locales and languages. Note also
that My Documents is a virtual folder, whose contents are stored in
another real folder. For example, on Windows 7, "My Documents" is
really an alias for "Documents". The environ variables give you the
"My Documents" folder while GetSpecialFolder gives you "Documents".

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com






On Thu, 8 Apr 2010 08:19:02 -0700, MikeZz
wrote:

Hi,
I have a file that's shared on multiple computers using different OS and
versions of Excel....
Windows 7, XP Pro, Excel 03 and Excel 07.

Is there a common function that can get the true location of the "My
Documents" folder for all the above combinations?

I guess I wouldn't need the actual folder name if there is a common alias I
could grab on to. It just has to be able to work if someone moved the "My
Documents" location to a non-default drive or folder.

Thanks!

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
Excel 2007 + PIA + Win7 + VS2010 = yikes!?!? sfun28 Excel Programming 0 February 5th 10 02:59 PM
How to open Two copies of Excel under Win7 Roger Excel Discussion (Misc queries) 6 December 26th 09 04:52 PM
Win7 and Excel07 - Items appear in NEW Excel Taskbar icon not Exis tomhass Excel Discussion (Misc queries) 0 November 16th 09 03:18 PM
Embedding Word Docs into Excel Worksheets and Then Printing The Word Docs mr_melvis Excel Worksheet Functions 1 April 8th 05 03:00 AM
converting excel docs to word docs rolercster New Users to Excel 2 January 4th 05 07:11 PM


All times are GMT +1. The time now is 06:47 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"