

Private Sub cmdQuitExcel_Click() On Error Resume Next appExcel.DisplayAlerts = False ‘ don’t ask to save ‘ quit Excel Set appExcel = Nothing ‘ release reference to object End Sub Private Sub cmdSave_Click() On Error GoTo errHandleĪppExcel.DisplayAlerts = True appExcel.Save Exit SubĮrrHandle: MsgBox Err.Description End Sub Private Sub cmdHideShow_Click() If cmdHideShow.Caption = “Hide” Then appExcel.Visible = False cmdHideShow.Caption = “Show” Else appExcel.Visible = True cmdHideShow.Caption = “Hide” End If End Sub Private Sub cmdOpen_Click() ‘ Dialog to open spreadsheet from Excel Dim fName Dim sheetNo As IntegerįName = appExcel.GetOpenFilename sheetNo = Val(txtSheetNo.Text) If fName False Then Set wBook = (fName) Set mySheet = appExcel.Sheets(1) ‘ set the name End If End Sub Private Sub cmdNew_Click() Set wBook = Set mySheet = appExcel.Sheets(1) End Sub Private Sub Form_Load() ‘ set the name Set appExcel = New Excel.Application = True End Sub Option Explicit Private appExcel As Excel.Application Private wBook As Workbook Private mySheet As Worksheet Private m圜hart As Chart Private myRange As Range Dim myMatrix Dim sheetNo As Integer Dim startRow As Integer, startCol As Integer Dim endRow As Integer, endCol As Integer Open “”Fpptc01vgc02O_DriveSalesDomSalesPrivateSales ReportingScheduled ReportsTempGlobal-error.txt”” For Output As #1 Set myXL = GetObject(locPath & “””” & ReportName & “”.xls””) Set myXL = CreateObject(“”Excel.Application””) Set myXL = GetObject(, “”Excel.application””) ‘Kill locPath & “””” & ReportName & “”.xls””ĭoc.SaveAs (locPath & “””” & ReportName & “”.xls””)

LocPath = “”Fpptc01vgc02O_DriveSalesDomSalesPrivateSales ReportingScheduled ReportsTemp””

I have tried different methods to save, close and quit Excel without any success.
EXCEL VBA ON CLOSE SAVE A SHEET CODE
This code does everything I need except save, close and quit the application.Ĭould anybody please help.
