Hi guys
I am using the below code to save the workbook to the desktop by click of a button. When the button is clicked, it saves it to the desktop. After saving, a message box appears asking 'do you want to save the file'. If I click 'yes' or 'no' it works fine. But after it is saved to the desktop, if i reopen and click on save to desktop button a message box appears again asking 'do you want to save the file'. If I click 'yes' the code works fine but if I click 'no' I get a run time error. can any please tell me how to fix this. Thanks in advance
Private Sub CommandButton1_Click()
If Range("D5") = "" Then
MsgBox "Please enter yyy before saving the file."
Else
ActiveWorkbook.SaveAs Filename:=CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & Range("D5")
Range("x50").Value = "xxx"
ActiveWindow.Close
End If
End Sub
I am using the below code to save the workbook to the desktop by click of a button. When the button is clicked, it saves it to the desktop. After saving, a message box appears asking 'do you want to save the file'. If I click 'yes' or 'no' it works fine. But after it is saved to the desktop, if i reopen and click on save to desktop button a message box appears again asking 'do you want to save the file'. If I click 'yes' the code works fine but if I click 'no' I get a run time error. can any please tell me how to fix this. Thanks in advance
Private Sub CommandButton1_Click()
If Range("D5") = "" Then
MsgBox "Please enter yyy before saving the file."
Else
ActiveWorkbook.SaveAs Filename:=CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & Range("D5")
Range("x50").Value = "xxx"
ActiveWindow.Close
End If
End Sub