Initially I assumed "VBPropercase would do the trick and it didn't, so to work around this I used a piece of code to force this to happen.
Code: Select all
Public Function MakeProperCase(ByVal strString As String) As String
Dim strText() As String
Dim strTemp As String
Dim i As Integer
strText = Split(strString)
For i = 0 To UBound(strText)
If i = 0 Then
strTemp = strTemp & StrConv(strText(0), vbProperCase)
ElseIf Right$(strText(i - 1), 1) Like "[.!?]" Then
strTemp = strTemp & StrConv(strText(i), vbProperCase)
Else
strTemp = strTemp & StrConv(strText(i), vbLowerCase)
End If
strTemp = strTemp & Space$(1)
Next i
MakeProperCase = strTemp
End Function
Code: Select all
Private Sub Command2_Click()
Dim strFolderName As String
Dim strFolderName2 As String
Me.Label1.Visible = True
Me.Label2.Visible = True
Me.txtOtherMan.Visible = True
Me.txtOtherMod.Visible = True
Me.txtFile.Visible = True
Dim FMan As String
Dim FMod As String
Dim FFile As String
FMan = InputBox("ManuFacturer")
FMod = InputBox("Model")
FFile = InputBox("Document Name")
Me.txtOtherMan.Text = FMan
Me.txtOtherMod.Text = FMod
Me.txtFile.Text = FFile
If FMan = "" Then
MsgBox "No Manufacturer", vbInformation, ""
Exit Sub
End If
If FMod = "" Then
MsgBox "No Model", vbInformation, ""
Exit Sub
End If
If FFile = "" Then
MsgBox "No File", vbInformation, ""
Exit Sub
End If
strFolderName = "L:\mmpdf\QuickMethod\" & MakeProperCase(FMan) & "\"
strFolderName2 = "L:\mmpdf\QuickMethod\" & MakeProperCase(FMan) & "\" & MakeProperCase(FMod) & "\"
If Dir(strFolderName, vbDirectory) = "" Then
MkDir strFolderName
End If
If Dir(strFolderName2, vbDirectory) = "" Then
MkDir strFolderName2
End If
FFile = Replace$(StrConv(FFile, vbProperCase), " ", "-")
FileCopy Me.txtMethDesc.Text, strFolderName2 & FFile & ".pdf"
MsgBox "Method Saved to Collection", vbInformation, ""
Unload Me
End Sub
The duplicate folder is then none deletable and causing problems.
Can anyone review my code and see if there is anything untowards with it>?
Thanks