Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to get path for "my documents"

Dear gurus:
With environ() I can find homepath or userprofile, but how can I get the
path for "my documents"? Thanks in advance!
wang
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default How to get path for "my documents"


"Wang" schreef in bericht
...
Dear gurus:
With environ() I can find homepath or userprofile, but how can I get the
path for "my documents"? Thanks in advance!
wang



It seems the good old Windows Script Host offers help:

Dim wsh
Set wsh = CreateObject("WScript.Shell")
MsgBox wsh.SpecialFolders("MyDocuments")
Set wsh = Nothing




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How to get path for "my documents"

You can see all the info available from Environ with something like this:

Dim i As Long
For i = 1 To 35 'Or some suitable number
Debug.Print Environ(i)
Next

However, do not use the numeric index in production, as there is no
guarentee how each computer is organised.
Use the text instead
Environ("USERPROFILE")

Orherwise there is the API route:
http://www.mvps.org/access/api/api0054.htm

NickHK

"Wang" wrote in message
...
Dear gurus:
With environ() I can find homepath or userprofile, but how can I get the
path for "my documents"? Thanks in advance!
wang



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to get path for "my documents"

It works fine. Thank you, Moon!

"moon" wrote:


"Wang" schreef in bericht
...
Dear gurus:
With environ() I can find homepath or userprofile, but how can I get the
path for "my documents"? Thanks in advance!
wang



It seems the good old Windows Script Host offers help:

Dim wsh
Set wsh = CreateObject("WScript.Shell")
MsgBox wsh.SpecialFolders("MyDocuments")
Set wsh = Nothing





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to get path for "my documents"

I've used this loop to print out all the environment variables and have not
found entry for "mydocuments". The API is quite unfamiliar to me (I've never
worked with it). But the mothod Moon told me (see his reply) has solved my
question. API might be a topic for my future study. Thank you for your reply!
wang

"NickHK" wrote:

You can see all the info available from Environ with something like this:

Dim i As Long
For i = 1 To 35 'Or some suitable number
Debug.Print Environ(i)
Next

However, do not use the numeric index in production, as there is no
guarentee how each computer is organised.
Use the text instead
Environ("USERPROFILE")

Orherwise there is the API route:
http://www.mvps.org/access/api/api0054.htm

NickHK

"Wang" wrote in message
...
Dear gurus:
With environ() I can find homepath or userprofile, but how can I get the
path for "my documents"? Thanks in advance!
wang






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How to get path for "my documents"

But you have
Environ("USERPROFILE") & "\My Documents"

Not sure if this is valid an non-English systems, although the API will
always work.

NickHK

"Wang" wrote in message
...
I've used this loop to print out all the environment variables and have

not
found entry for "mydocuments". The API is quite unfamiliar to me (I've

never
worked with it). But the mothod Moon told me (see his reply) has solved my
question. API might be a topic for my future study. Thank you for your

reply!
wang

"NickHK" wrote:

You can see all the info available from Environ with something like

this:

Dim i As Long
For i = 1 To 35 'Or some suitable number
Debug.Print Environ(i)
Next

However, do not use the numeric index in production, as there is no
guarentee how each computer is organised.
Use the text instead
Environ("USERPROFILE")

Orherwise there is the API route:
http://www.mvps.org/access/api/api0054.htm

NickHK

"Wang" wrote in message
...
Dear gurus:
With environ() I can find homepath or userprofile, but how can I get

the
path for "my documents"? Thanks in advance!
wang






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to get path for "my documents"

That's the point! The German version has "\Eigene Dateien" instead of "\My
Documents".

"NickHK" wrote:

But you have
Environ("USERPROFILE") & "\My Documents"

Not sure if this is valid an non-English systems, although the API will
always work.

NickHK

"Wang" wrote in message
...
I've used this loop to print out all the environment variables and have

not
found entry for "mydocuments". The API is quite unfamiliar to me (I've

never
worked with it). But the mothod Moon told me (see his reply) has solved my
question. API might be a topic for my future study. Thank you for your

reply!
wang

"NickHK" wrote:

You can see all the info available from Environ with something like

this:

Dim i As Long
For i = 1 To 35 'Or some suitable number
Debug.Print Environ(i)
Next

However, do not use the numeric index in production, as there is no
guarentee how each computer is organised.
Use the text instead
Environ("USERPROFILE")

Orherwise there is the API route:
http://www.mvps.org/access/api/api0054.htm

NickHK

"Wang" wrote in message
...
Dear gurus:
With environ() I can find homepath or userprofile, but how can I get

the
path for "my documents"? Thanks in advance!
wang






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default How to get path for "my documents"

Use the API route in the link then, with
Public Const CSIDL_PERSONAL = &H5

NickHK

"Wang" ...
That's the point! The German version has "\Eigene Dateien" instead of "\My
Documents".

"NickHK" wrote:

But you have
Environ("USERPROFILE") & "\My Documents"

Not sure if this is valid an non-English systems, although the API will
always work.

NickHK

"Wang" wrote in message
...
I've used this loop to print out all the environment variables and have

not
found entry for "mydocuments". The API is quite unfamiliar to me (I've

never
worked with it). But the mothod Moon told me (see his reply) has solved
my
question. API might be a topic for my future study. Thank you for your

reply!
wang

"NickHK" wrote:

You can see all the info available from Environ with something like

this:

Dim i As Long
For i = 1 To 35 'Or some suitable number
Debug.Print Environ(i)
Next

However, do not use the numeric index in production, as there is no
guarentee how each computer is organised.
Use the text instead
Environ("USERPROFILE")

Orherwise there is the API route:
http://www.mvps.org/access/api/api0054.htm

NickHK

"Wang" wrote in message
...
Dear gurus:
With environ() I can find homepath or userprofile, but how can I
get

the
path for "my documents"? Thanks in advance!
wang








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
Delete emty file names from "recent documents" Excel Touble in Excel Excel Discussion (Misc queries) 2 March 22nd 10 08:10 PM
How to show "DRAFT" on print versions of test documents. chopspop Excel Discussion (Misc queries) 4 November 23rd 08 08:28 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
How do I move a document from "recent items" to "documents" John Gerke in Central Oregon New Users to Excel 1 March 2nd 08 08:31 AM
Problems updating shared documents which used "Lookup" function Yeam69 Excel Discussion (Misc queries) 0 June 21st 06 08:42 AM


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

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"