Rob4077
asked on
Find My Documents folder
I have a MS Access application that needs to be deployed in over 300 different locations with varying computer systems. I therefore propose using SageKey to deploy the app to avoid configuration issues with other versions of MS Access. I therefore plan on saving the FE and BE of my app in one of the recommended locations for apps.
However my app requires the user to save a csv or xls file in a specific location.. The app looks in that folder and if it finds files it imports the data and moves the imported file to an archive subfolder. I thought it best to create a subfolder in My Documents with my app name where they could easily save the csv and xls files and a subfolder of that folder to act as the archive.
How can I reliably find the location of the My Documents folder using VBA? Or is there a recommended alternative approach to this situation?
However my app requires the user to save a csv or xls file in a specific location.. The app looks in that folder and if it finds files it imports the data and moves the imported file to an archive subfolder. I thought it best to create a subfolder in My Documents with my app name where they could easily save the csv and xls files and a subfolder of that folder to act as the archive.
How can I reliably find the location of the My Documents folder using VBA? Or is there a recommended alternative approach to this situation?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the added suggestion. I will give some thought and discuss with the stakeholders before finalising. Thanks
For what its worth, you can open the User's profile directory quickly by start->run and typing a single dot/period/full stop.
ASKER
Thanks for the tip!
ASKER
Hi Gustav, if you're still linked to this question, I just tried running a debug.print Dir(Environ("USERPROFILE") & "\Documents\", vbNormal) in my code and it generates a blank
ASKER
BTW ignore last post - it's an easy adjustment to get what I need.,
Well, these should give you the folder itself:
? Dir(Environ("USERPROFILE") & "\Documents", vbDirectory)
? Dir(Environ("USERPROFILE") & "\Doc*", vbDirectory)
If not, this method seems not to be bullet-proof.
/gustav
? Dir(Environ("USERPROFILE")
? Dir(Environ("USERPROFILE")
If not, this method seems not to be bullet-proof.
/gustav
ASKER
Hi Gustav, I trialled it on a machine that resides on a server and it doesn't work, My Documents is redirected elsewhere and I can't rely on this method to make it work. I don't know if it's fair to assume that every PC will have a C:\ but at the moment I am tending towards that. I could let them use their preferred location as per Sheils' suggestion but that assumes the users will be able to sensibly pick a location during installation. The alternative is to use Environ$(“USERPROFILE”) & “YourFolderNameHere”, which does work, but again may be a little harder to find than C:\. Many of my users are not computer savvy at all.
...but again may be a little harder to find than C:\. Many of my users are not computer savvy at all.
This is why I stated that you can open the profile folder by Start->Run->. :)
You can tell users to do this, then tell them to open the folder "YourFolderNameHere" within the window that opens. Alternatively you could create a shortcut to this folder programatically or just simply programatically open it?
ASKER
With the variability possible, might I be better off getting them to save the csv and xls files in C:\MyApp instead of Documents or My Documents? I am not sure if most systems allow users to save to main drive folders
Otherwise it's sounding like strFile = Dir(Environ("USERPROFILE")