J
JayM
I have created a macro which uses a userform to retrieve data to create a
folder on the network. That works fine. I have added error check to see if
the folder already exists and this works fine. The problem is getting the
macro to go back to the userform for them to amend the folder name for it to
be created.
The code follows, if anyone can help me out that would be great. I am quite
new to VBA
Private Sub cmdOK_Click()
Dim MyFilePath As String
Dim TestFolder
Dim TestAlphaFolder
If cboDept.Value = "Stourport" Then MyFilePath = "w:\data\_Clients\"
If cboDept.Value = "Worcester" Then MyFilePath = "w:\data\_Clients\"
If cboDept.Value = "Kidderminster - Business" Then _
MyFilePath = "w:\data\Business\_Clients\"
If cboDept.Value = "Kidderminster - Civil" Then _
MyFilePath = "w:\data\Business\_Clients\"
If cboDept.Value = "Kidderminster - Crime" Then _
MyFilePath = "w:\data\Business\_Clients\"
If cboDept.Value = "Kidderminster - Family" Then _
MyFilePath = "w:\data\Business\_Clients\"
If cboDept.Value = "Kidderminster - Probate" Then _
MyFilePath = "w:\data\Business\_Clients\"
If cboDept.Value = "Kidderminster - Property" Then _
MyFilePath = "w:\data\Business\_Clients\"
TestFolder = Dir(MyFilePath & txtMyFolderName) & "\"
If Len(TestFolder) = 0 Then
Handler:
MkDir MyFilePath & Left(txtMyFolderName, 1) & "\"
ClientFolders:
MkDir MyFilePath & Left(txtMyFolderName, 1) & "\" & txtMyFolderName
MkDir MyFilePath & Left(txtMyFolderName, 1) & "\" & txtMyFolderName &
"\Bills"
MkDir MyFilePath & Left(txtMyFolderName, 1) & "\" & txtMyFolderName &
"\Documents"
MkDir MyFilePath & Left(txtMyFolderName, 1) & "\" & txtMyFolderName &
"\Correspondence"
MsgBox (MyFilePath & txtMyFolderName & " created!")
Else
txtMyFolderName = InputBox("File " & txtMyFolderName & _
" already exists" & Chr(10) & Chr(10) & "Please type another folder
name:", "File Exists", txtMyFolderName)
End If
frmFolderCreation.Hide
End Sub
folder on the network. That works fine. I have added error check to see if
the folder already exists and this works fine. The problem is getting the
macro to go back to the userform for them to amend the folder name for it to
be created.
The code follows, if anyone can help me out that would be great. I am quite
new to VBA
Private Sub cmdOK_Click()
Dim MyFilePath As String
Dim TestFolder
Dim TestAlphaFolder
If cboDept.Value = "Stourport" Then MyFilePath = "w:\data\_Clients\"
If cboDept.Value = "Worcester" Then MyFilePath = "w:\data\_Clients\"
If cboDept.Value = "Kidderminster - Business" Then _
MyFilePath = "w:\data\Business\_Clients\"
If cboDept.Value = "Kidderminster - Civil" Then _
MyFilePath = "w:\data\Business\_Clients\"
If cboDept.Value = "Kidderminster - Crime" Then _
MyFilePath = "w:\data\Business\_Clients\"
If cboDept.Value = "Kidderminster - Family" Then _
MyFilePath = "w:\data\Business\_Clients\"
If cboDept.Value = "Kidderminster - Probate" Then _
MyFilePath = "w:\data\Business\_Clients\"
If cboDept.Value = "Kidderminster - Property" Then _
MyFilePath = "w:\data\Business\_Clients\"
TestFolder = Dir(MyFilePath & txtMyFolderName) & "\"
If Len(TestFolder) = 0 Then
Handler:
MkDir MyFilePath & Left(txtMyFolderName, 1) & "\"
ClientFolders:
MkDir MyFilePath & Left(txtMyFolderName, 1) & "\" & txtMyFolderName
MkDir MyFilePath & Left(txtMyFolderName, 1) & "\" & txtMyFolderName &
"\Bills"
MkDir MyFilePath & Left(txtMyFolderName, 1) & "\" & txtMyFolderName &
"\Documents"
MkDir MyFilePath & Left(txtMyFolderName, 1) & "\" & txtMyFolderName &
"\Correspondence"
MsgBox (MyFilePath & txtMyFolderName & " created!")
Else
txtMyFolderName = InputBox("File " & txtMyFolderName & _
" already exists" & Chr(10) & Chr(10) & "Please type another folder
name:", "File Exists", txtMyFolderName)
End If
frmFolderCreation.Hide
End Sub