Module: SystemFolders in Category Windows : System Information from Total Visual SourceBook

Retrieve and create system and user folders in VB6 and VBA with 32 and 64-bit Windows API calls.

Procedure Name Type Description
(Declarations) Declarations Declarations and private variables for the modSystemFolders module.
DisplayAllSystemFolders Procedure Output all the system folder names to the Immediate Window. Some folders may duplicate each other or not be defined.
AppDataFolder Procedure Get the user's application data folder (usually C:\Users\UserName\AppData\ where UserName is the login name). The user has read and write permissions to this folder.
AppDataSubFolder Procedure Get the user's application data folder and application name. The user has read and write permissions to this folder.
AdminToolsFolder Procedure Get the user's Microsoft administrative tools folder.
CookiesFolder Procedure Get the user's Microsoft cookies folder.
DesktopFolder Procedure Get the user's desktop folder.
DesktopFolderPublic Procedure Get the public desktop folder.
DocumentsFolder Procedure Get the user's personal documents folder.
DocumentsFolderPublic Procedure Get the user's public documents folder.
FavoritesFolder Procedure Get the user's favorites folder.
FavoritesFolderPublic Procedure Get the public favorites folder.
FontsFolder Procedure Get the Windows fonts folder.
HistoryFolder Procedure Get the user's Microsoft history folder.
InternetCacheFolder Procedure Get the user's Microsoft internet cache folder.
LocalAppDataFolder Procedure Get the user's local application data folder.
NetworkShortcutsFolder Procedure Get the user's network shortcuts folder.
PicturesFolder Procedure Get the user's pictures folder.
PrinterShortcutsFolder Procedure Get the user's printer shortcut folder.
ProfileFolder Procedure Get the user's profile folder.
ProgramFilesFolder Procedure Get the Program Files folder.
ProgramFilesCommonFolder Procedure Get the common files folder in the Program Files folder.
RecentFolder Procedure Get the user's recent folder.
SendToFolder Procedure Get the user's send to folder.
StartMenuFolder Procedure Get the user's Start Menu folder.
StartMenuFolderPublic Procedure Get the public Start Menu folder.
StartUpFolder Procedure Get the user's startup folder.
StartUpFolderPublic Procedure Get the public startup folder.
SystemFolder Procedure Get the Windows Systems folder.
SystemFolder32 Procedure Get the 32-bit Windows Systems folder. For 64-bit O/S, it's usually.
TemplateFolder Procedure Get the user's template folder.
TemplateFolderPublic Procedure Get the user's public template folder.
WindowsFolder Procedure Get the Windows folder.
ProgramDataFolder Procedure Get the common application data folder.
ProgramDataSubFolder Procedure Get an application's folder name in the common application data folder (usually C:\ProgramData\), and optionally create it if it doesn't exist.
GetSystemFolder Procedure Get a system folder name, and optionally create it if it doesn't exist.
CheckMakeSubFolders Procedure See if a folder exists and optionally create it.
MakeSubFolders Procedure Make a folder (directory) and subfolders if it doesn't already exist. This improves upon the basic MkDir command which only creates a folder in a folder that already exists.
' Example of modSystemFolders
'
' To use this example, create a new module and paste this code into it.
' Then run the procedure by putting the cursor in the procedure and pressing:
'    F5 to run it, or
'    F8 to step through it line-by-line (see the Debug menu for more options)

Private Sub Example_modSystemFolders()
  ' Comments: Example of using the modSystemFolders module to get Windows system folders in VB6 and VBA with 32 and 64 bit Windows API calls.
  '           Run this procedure and see the information in the Immediate Window.

  ' This first part is a display of all the system folders in one command
  Debug.Print "========================="
  Debug.Print "DisplayAllSystemFolders "
  Debug.Print "------------------"
  DisplayAllSystemFolders
  Debug.Print "========================="

  ' The following are individual procedure calls that retrieve specific Windows system folders
  Debug.Print "AdminTools         : " & AdminToolsFolder

  ' The user has full permissions to their AppData folders:
  Debug.Print "AppData            : " & AppDataFolder
  Debug.Print "AppDataSub         : " & AppDataSubFolder("FMS", True)

  Debug.Print "Cookies            : " & CookiesFolder
  Debug.Print "Desktop            : " & DesktopFolder
  Debug.Print "DesktopPublic      : " & DesktopFolderPublic
  Debug.Print "Documents          : " & DocumentsFolder
  Debug.Print "DocumentsPublic    : " & DocumentsFolderPublic
  Debug.Print "Favorites          : " & FavoritesFolder
  Debug.Print "FavoritesPublic    : " & FavoritesFolderPublic
  Debug.Print "Fonts              : " & FontsFolder
  Debug.Print "History            : " & HistoryFolder
  Debug.Print "InternetCache      : " & InternetCacheFolder
  Debug.Print "LocalAppData       : " & LocalAppDataFolder
  Debug.Print "NetworkShortcuts   : " & NetworkShortcutsFolder
  Debug.Print "Pictures           : " & PicturesFolder
  Debug.Print "PrinterShortcuts   : " & PrinterShortcutsFolder
  Debug.Print "Profile            : " & ProfileFolder
  Debug.Print "ProgramData        : " & ProgramDataFolder
  Debug.Print "ProgramDataSub     : " & ProgramDataSubFolder("FMS", True)
  Debug.Print "ProgramFilesCommon : " & ProgramFilesCommonFolder
  Debug.Print "ProgramFiles       : " & ProgramFilesFolder
  Debug.Print "Recent             : " & RecentFolder
  Debug.Print "SendTo             : " & SendToFolder
  Debug.Print "StartMenu          : " & StartMenuFolder
  Debug.Print "StartMenuPublic    : " & StartMenuFolderPublic
  Debug.Print "StartUp            : " & StartUpFolder
  Debug.Print "StartUpPublic      : " & StartUpFolderPublic
  Debug.Print "System             : " & SystemFolder
  Debug.Print "System 32-bit      : " & SystemFolder32
  Debug.Print "Template           : " & TemplateFolder
  Debug.Print "TemplatePublic     : " & TemplateFolderPublic
  Debug.Print "Windows            : " & WindowsFolder
End Sub

Total Visual SourceBook The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!

Additional Resources

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!


View all FMS products for Microsoft Access All Our Microsoft Access Products

Reviews

Reader Choice Award for MS Access Source Code Library
Reader Choice

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

SourceBook Info

Additional Info

Question

 

 

Free Product Catalog from FMS