Skip to main content

Get user desktop and make a folder

Get user desktop and make a folder

Dim DeskTop As String
  Dim WSH As Object
  Dim GetDesktopPath As String
  Dim MainFolder As String
  
    Set WSH = CreateObject("WScript.Shell")
    DeskTop = WSH.SpecialFolders("desktop")
    
    GetDesktopPath = DeskTop
    Set WSH = Nothing
    
MainFolder = "Your Folder Name" 'Folder to be created on the desktop
Dim Path As String
Path = GetDesktopPath & "\" & MainFolder &"\"
If Len(Dir(Path, vbDirectory)) = 0 Then
MkDir (Path)
End If