skeeeter56
New Member
- Joined
- Nov 26, 2016
- Messages
- 42
- Office Version
- 2019
- Platform
- Windows
I have a workbook that is used to produce a leave form. It all works from a list of peoples names on the worksheet Staff Information and 2 pop up calender's to add the dates.
Once the data is complete it is used to print a form. The data does not need to be saved, it is only used to produce and print this form.
It has 2 buttons one to print and one to clear clear so can produce another. I also have a close button, this is what I am having issues with.
I had code that when you run it indeed did not save or prompt to save, but it closed all excel workbooks that were open.
With the below code I am trying to close the just this workbook with out saving or prompting to save.
In essence this file is a template that needs to be blank when opened, it is also stored on a SharePoint site and that is where it is opened from.
This is the code I currently have
I have tried varuious ways to achieve what I want but so far it has eluded me.
I am hoping somone may be able to assist
Once the data is complete it is used to print a form. The data does not need to be saved, it is only used to produce and print this form.
It has 2 buttons one to print and one to clear clear so can produce another. I also have a close button, this is what I am having issues with.
I had code that when you run it indeed did not save or prompt to save, but it closed all excel workbooks that were open.
With the below code I am trying to close the just this workbook with out saving or prompting to save.
In essence this file is a template that needs to be blank when opened, it is also stored on a SharePoint site and that is where it is opened from.
This is the code I currently have
VBA Code:
Private Sub CommandButton1_Click()
Application.DisplayAlerts = False
If Workbooks.Count < 2 Then
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.Quit
Else
ThisWorkbook.Close SaveChanges:=False
End If
End Sub
I am hoping somone may be able to assist