Created
March 2, 2022 01:26
-
-
Save lundeen-bryan/3e4ac8012b43a2312d69e820dadadb8b to your computer and use it in GitHub Desktop.
ReturnMyDocsPath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Attribute VB_Name = "fnc_ReturnMyDocsPath" | |
' namespace=vba-files/Modules | |
' filename=fnc_ReturnMyDocsPath.bas | |
Option Explicit | |
Const sep As String = "\" | |
Public Function ReturnMyDocsPath_fnc() As String | |
Dim user As String | |
Dim windowsScriptShell As Object | |
Set windowsScriptShell = CreateObject("WScript.Shell") | |
ReturnMyDocsPath_fnc = windowsScriptShell.SpecialFolders("MyDocuments") & sep | |
''=========================================================================================== | |
'' Procedure: ......... fnc_ReturnMyDocsPath.bas/ReturnMyDocsPath_fnc | |
'' Description: ....... returns the user's my documents path if it's the DSH OneDrive folder. | |
'' Version: ........... 1.0.0 - major.minor.patch | |
'' Created: ........... 2022-01-31 | |
'' Updated: ........... 2022-01-31 | |
'' Module URL: ........ none | |
'' Installs to: ....... vba-files/Modules | |
'' Compatibility: ..... Excel,Word,etc. | |
'' Contact Author: .... [email protected] | |
'' Copyright: ........ none ©2022. All rights reserved. | |
'' Called by: ......... other_subs | |
'' Calls to: .......... other_subs | |
'' Parameters: ........ parameters | |
'' Return: ............ type param_description | |
'' Notes: ............. _ | |
'' (1) A list of all "SpecialFolders" can be found at https://archive.fo/LQecg | |
'' (2) The note below pertains to alternate ways to get the MyDocs folder: | |
'' Environ$("USERNAME") | |
'' Mid(Environ("homepath"), 8) | |
'' "C:\Users\" & user & "\OneDrive - Department of State Hospitals\Documents" | |
''=========================================================================================== | |
End Function | |
Private Sub sub_TestGetDocsPath() | |
' | |
' Desc: ....... Test for return mydocs path. | |
' | |
' Version: .... 1.0.0 | |
' Call to: .... none | |
' | |
Debug.Print "The MyDocuments folder on this machine is" & vbCrLf & _ | |
ReturnMyDocsPath_fnc | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment