Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA How to get path to The Current Users Application data folder?

In general,

Using VBA, how do I determine where the Current users Application Data folder is?

The FileSystemObjects special folders only knows about 3 folders

  • WindowsFolder
  • SystemFolder
  • TemporaryFolder

Specifically, I need a Word Macro to copy a file to the a folder under the Application Data folder.

e.g. In VB.Net I can use My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData to do this

like image 371
Binary Worrier Avatar asked Jun 10 '09 15:06

Binary Worrier


2 Answers

You can use Environ("AppData") to get this path. Environ will pull any system variable, which can be found by using the set command at the DOS prompt.

like image 125
Eric Avatar answered Oct 12 '22 01:10

Eric


Using advapi32.dll, you can get the USERPROFILE via

Environ("USERPROFILE")

Connect this with the "Application Data" directory (which has a standard, specific name) to get what you want

CStr(Environ("USERPROFILE") & "\Application Data")

For more information, check out MSDN

like image 27
Andrew Scagnelli Avatar answered Oct 12 '22 03:10

Andrew Scagnelli