Private Sub Save_As()
'Begins Error Handling Code
On Error GoTo Helper
'Creates the SaveAs "Current Voyage" on the Noon Sheet
Dim path1 As String
Dim path2 As String
Dim Path3 As String
Dim myfilename As String
Dim cpathname As String
Dim dpathname As String
Dim epathname As String
Dim fpathname As String
Dim resp As Integer
Dim name As String
With Worksheets("Notes")
path1 = .Range("O16")
name = .Range("N4")
path2 = .Range("O18")
Path3 = .Range("U16")
End With
myfilename = path2
bpathname = Environ("Userprofile") & "\" & path1
cpathname = Worksheets("Developer").Range("E42") & "\" & path1
'dpathname = Environ("Userprofile") & "\" & path1
epathname = dpathname & "\" & Path3
fpathname = epathname & "\"
If Worksheets("Developer").Range("I46").Value = "Network" Then
dpathname = cpathname
Else
dpathname = bpathname
End If
ActiveSheet.EnableCalculation = False
If ActiveWorkbook.name = "Master Voyage Report.xlsm" Then
resp = MsgBox("You are trying to save the " & myfilename & " to:" & vbCrLf & fpathname & myfilename & ".xlsm", vbYesNo, name)
If resp = vbYes Then
If Len(Dir(fpathname, vbDirectory)) = 0 Then
If Len(Dir(epathname, vbDirectory)) = 0 Then
If Len(Dir(dpathname, vbDirectory)) = 0 Then
MkDir (dpathname)
End If
MkDir (epathname)
End If
MkDir (fpathname)
End If
ActiveWorkbook.SaveAs Filename:=fpathname & myfilename & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
'Application Closer
If Workbooks.Count > 1 Then
ActiveWorkbook.Close
Else
Application.Quit
End If
ElseIf vbNo Then
Exit Sub
ElseIf vbCancel Then
Exit Sub
End If
ElseIf ActiveWorkbook.name = myfilename Then
ActiveWorkbook.Save
'Application Closer
If Workbooks.Count > 1 Then
ActiveWorkbook.Close
Else
Application.Quit
End If
Else: ActiveWorkbook.Save
'Application Closer
If Workbooks.Count > 1 Then
ActiveWorkbook.Close
Else: Application.Quit
End If
End If
'Error Clearing Code
Exit Sub
Helper:
resp = MsgBox("We're sorry to see you've encountered an error." & vbCrLf & vbCrLf & "To proceed, we recommend you contact the Developer " & _
"with error codes [1147] and " & "[" & Err.Number & "-" & Err.Description & "]." & vbCrLf & vbCrLf & "To attempt to patch your problem at least " & _
"temporarily, we recommend you click [Yes] to see help directions. Would you like to continue?", vbYesNoCancel, name)
If resp = vbYes Then
Call Error_Handle(sprocname, Err.Number, Err.Description)
ElseIf resp = vbNo Then
Exit Sub
ElseIf resp = vbCancel Then
Exit Sub
End If
End Sub