Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 + PIA + Win7 + VS2010 = yikes!?!? | Excel Programming | |||
How to open Two copies of Excel under Win7 | Excel Discussion (Misc queries) | |||
Win7 and Excel07 - Items appear in NEW Excel Taskbar icon not Exis | Excel Discussion (Misc queries) | |||
Embedding Word Docs into Excel Worksheets and Then Printing The Word Docs | Excel Worksheet Functions | |||
converting excel docs to word docs | New Users to Excel |