Hi Guys,
I'm sometimes getting a runtime error on the "ActiveWorkbook.SaveAs" line
Other times it works like a dream. I'm confused...
I'm sometimes getting a runtime error on the "ActiveWorkbook.SaveAs" line
Other times it works like a dream. I'm confused...
Rich (BB code):
Sub TestForDirAndSave()
If MsgBox("Are you sure?", vbOKCancel, "Save?") = vbCancel Then Exit Sub
Dim strDir As String
strDir = Sheets("Todoist Checklist").Range("b48")
strDir2 = Sheets("Todoist Checklist").Range("c48")
strDir3 = Sheets("Todoist Checklist").Range("d48")
'Makes sure there are values in boxes so folders with value 0 are not created
Do Until False
If Sheet11.Range("d7") = "" Then
MsgBox "You must add a Referral Facility"
Exit Sub
Else
If Sheet11.Range("d24") = "" Then
MsgBox "You must add a LOB"
Exit Sub
Else
If Sheet11.Range("D6") = "" Then
MsgBox "You must add a Client Name"
Exit Sub
Else
Exit Do
End If
End If
End If
Loop
'Checks if folder exists. if it doesn't it creates it.
Do Until False
If Dir(strDir, vbDirectory) = "" Then
MkDir strDir
Else
If Dir(strDir2, vbDirectory) = "" Then
MkDir strDir2
Else
If Dir(strDir3, vbDirectory) = "" Then
MkDir strDir3
Else
MsgBox "Client Folder Created"
Exit Do
End If
End If
End If
Loop
'Saves the file into the created folder.
ActiveWorkbook.SaveAs Sheet11.Range("C1") & "\" & Sheet11.Range("D6") & ", " & Sheet11.Range("D5") & "- PreQuote" & ".xlsm"
Sheet11.Range("a1").Value = "Saved"
End Sub