sassriverrat
Well-known Member
- Joined
- Oct 4, 2018
- Messages
- 655
I messed up an if here and was hoping someone could check it for me
Code:
Private Sub Save_As()'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 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
fpathname = Environ("Userprofile") & "\" & Path1 & "\" & Path3 & "\"
If ActiveWorkbook.name = "Master Voyage Report.xlsm" Then
ActiveSheet.EnableCalculation = False
resp = MsgBox("You are trying to save the " & myfilename & " to:" & vbCrLf & fpathname & myfilename & ".xlsm", vbYesNo, name)
If resp = vbYes Then
If Dir(fpathname, vbDirectory) = "" Then MkDir (fpathname)
Else: ActiveWorkbook.SaveAs Filename:=fpathname & myfilename & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
End If
'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
End Sub