Hi,
Your code works fine, it's just where you are placing it that is the problem. It needs to go into a sub or function which is why you are getting your error.
Try placing it in an event sub such as:
or place it in a function like:Code:'place a command button on your form Private Sub Command1_Click() Dim dirname As String, newdir As String Dim f As String dirname = "C:\Dev\" newdir = dirname & "NEWDIR" MkDir newdir newdir = newdir + "\" End Sub 'The code will run when you click Command1
and then you could call this function like:Code:Private Function MakeFolder(NewDir as String) Dim dirname As String dirname = "C:\Dev\" NewDir = dirname & NewDir MkDir NewDir End Function
Hope this helpsCode:Private Sub Form_Load() MakeFolder("NameOfNewDIR") End Sub
Shaun




Reply With Quote