W
WillRn
I am trying to modify a macro to enable my user to save a file locally on
their hard drive with a name and location that they specify. I keep getting
an "End if without Block If" compile error. Being very new to VBA code, I
can't seem to get the macro to work.
It is as follows:
Private Sub SaveMe_Click()
If NewName <> False Then
If Dir(NewName) <> "" Then Select Case MsgBox("File Exists. Overwrite
?", vbYesNoCancel + vbQuestion)
Case vbYes
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=NewName,
FileFormat:=xlWorkbookNormal
Application.DisplayAlerts = True
Case vbNo
Do
NewName = Application.GetSaveAsFilename( _
InitialFileName:=ActiveWorkbook.Path & "\" & NameAk,
FileFilter:="Excel Workbooks (*.xls), *.xls")
If NewName = False Then Exit Sub
Loop Until Dir(NewName) = ""
ActiveWorkbook.SaveAs Filename:=NewName,
FileFormat:=xlWorkbookNormal
Case Else
Exit Sub
End Select
Else
ActiveWorkbook.SaveAs Filename:=NewName,
FileFormat:=xlWorkbookNormal
End If
End If
End Sub
I know it is probably very simple, but I just can't seem to find the problem
.. . .
WillRn
their hard drive with a name and location that they specify. I keep getting
an "End if without Block If" compile error. Being very new to VBA code, I
can't seem to get the macro to work.
It is as follows:
Private Sub SaveMe_Click()
If NewName <> False Then
If Dir(NewName) <> "" Then Select Case MsgBox("File Exists. Overwrite
?", vbYesNoCancel + vbQuestion)
Case vbYes
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=NewName,
FileFormat:=xlWorkbookNormal
Application.DisplayAlerts = True
Case vbNo
Do
NewName = Application.GetSaveAsFilename( _
InitialFileName:=ActiveWorkbook.Path & "\" & NameAk,
FileFilter:="Excel Workbooks (*.xls), *.xls")
If NewName = False Then Exit Sub
Loop Until Dir(NewName) = ""
ActiveWorkbook.SaveAs Filename:=NewName,
FileFormat:=xlWorkbookNormal
Case Else
Exit Sub
End Select
Else
ActiveWorkbook.SaveAs Filename:=NewName,
FileFormat:=xlWorkbookNormal
End If
End If
End Sub
I know it is probably very simple, but I just can't seem to find the problem
.. . .
WillRn