What is the syntax to create a folder [new]

MkDir ("<filepath here>")
'example
'creates a folder called "newfolder" in the current Documents folder
MkDir ("C:\Users\Portia\Documents\newfolder")

To determine the filepath of a folder, click here.

 

Advertisements

What is the syntax to create a folder?

Dim FSo
Dim sFolder As String
sFolder = “<filepath for the folder you want to create>
Set FSO = CreateObject(“Scripting.FileSystemObject”)

If Not FSO.FolderExists(sFolder)Then
   FSO.CreateFolder(sFolder)
   MsgBox(“Folder Created”)
Else
   MsgBox(“Folder already Exists”)
End If

To learn how to find a folder’s filepath, click here.

What is the syntax to open a folder through a hyperlink?

Dim sXLFile As String
sFolder = “<folder’s filepath>
ActiveWorkbook.FollowHyperlink Address :=sFolder, NewWindow:=true

To learn how to find a folder’s filepath, click here.

‘example that opens the Downloads window upon clicking link
Dim sXLFile As String
sFolder = “C:\Users\jwatson\Downloads”
ActiveWorkbook.FollowHyperlink Address :=sFolder, NewWindow:=true