30 June 2020

Get the full path to any of the special Windows folders (Desktop, Start Menu etc).

Function GetSpecialFolderPath(NomeDirectory As Variant) As String

    '------------------------------------
    ' Valori possibili per NomeDirectory:
    '------------------------------------
    '    AllUsersDesktop
    '    AllUsersStartMenu
    '    AllUsersPrograms
    '    AllUsersStartup
    '    Desktop
    '    Favorites
    '    Fonts
    '    MyDocuments
    '    NetHood
    '    PrintHood
    '    Programs
    '    Recent
    '    SendTo
    '    StartMenu
    '    Startup
    '    Templates
    '------------------------------------
    
    Dim res As String
    Dim oWSHShell As Object

    Set oWSHShell = CreateObject("WScript.Shell")
    res = oWSHShell.SpecialFolders(NomeDirectory)
    
    Set oWSHShell = Nothing
    GetSpecialFolderPath = res
    
End Function


Via.

Attenzione: non cambiare il datatype di NomeDirectory"