PDA

View Full Version : Solved: directing VBA code to view current user's My Documents folder as data source



jeeves
11-01-2005, 12:34 PM
Hi there everyone...
Any help on this would be appreciated.

A while back, I had to customize an OTB third party application to work with our existing mail merge code (also customized, from yet another vendor).

Basically:
customization 1 allows user to select contacts and exports them to a csv file that is a hardcoded filename and location in c:\program files...
customization 2 then looks to the hardcoded csv file location and uses the exported data to place contact names in our existing letter, memo, etc templates.

But now, in order to allow for yet another customization, I need to direct both sets of code to write to the the My Documents folder of the current user.

Can anyone give me any hints on how to do this? I'm not even sure where to start...

Killian
11-02-2005, 06:47 AM
The user profile path is available as an Environment variable through the Environ function, so you can do thisDim strUserDocPath As String

strUserDocPath = Environ("USERPROFILE") & "\My Documents"

jeeves
11-04-2005, 11:29 AM
thank you! this worked. i'll mark this as solved.

TonyJollans
11-04-2005, 12:43 PM
If you're getting variable not defined, have you missed the quotes?

Yes, you could use the documents path but environ is better and should work.

MOS MASTER
11-04-2005, 04:43 PM
Hi, :hi:

Environ is one of the most powerfull functions that I know of to retrieve operating system environment info in a easy way.

Use this excellent KB to see what tresures it holds:
http://vbaexpress.com/kb/getarticle.php?kb_id=762

HTH, :whistle: