Hello,
I'm using code to reopen an excel worksheet from Access and apply formatting, but I'm having issues with getting it to save without creating a backup. Here is my code:
This creates a backup when it saves the changes, if I swap .Save out for .SaveAs , , , , , False or use .Close True it doesn't save at all. I'm not sure what I'm doing wrong. It looks like the "Always Create Backup" option is already set before it moves to the formatting, yet the spreadsheet is created with DoCmd.TransferSpreadsheet.
Russ
I'm using code to reopen an excel worksheet from Access and apply formatting, but I'm having issues with getting it to save without creating a backup. Here is my code:
Code:
If .chkAimCert.Value = True Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, _
"Aim Cert Not Received", strSheetFolder _
& "\Aim Certificate Not Received.xlsx", True
strSheetName = "Aim_Cert_Not_Received"
strSheetTitle = "Aim Certificate Not Received"
strSheetFile = "\Aim Certificate Not Received.xlsx"
Call DoFormat
End If
Code:
Public Sub DoFormat()
Set .objApp = New Excel.Application
With .objApp
[COLOR=yellowgreen]'.Visible = True[/COLOR]
.DisplayAlerts = False
Set objBook = .Workbooks.Open(.strSheetFolder & .strSheetFile, , False)
End With
With .objBook.Sheets(.strSheetName)
[COLOR=yellowgreen]...FORMATTING[/COLOR]
End With
With objBook
.Save
.Close False
End With
With objApp
.Quit
.DisplayAlerts = True
End With
End Sub
This creates a backup when it saves the changes, if I swap .Save out for .SaveAs , , , , , False or use .Close True it doesn't save at all. I'm not sure what I'm doing wrong. It looks like the "Always Create Backup" option is already set before it moves to the formatting, yet the spreadsheet is created with DoCmd.TransferSpreadsheet.
Russ