Save without creating a backup

rlarkin

Registered User.
Local time
Today, 14:11
Joined
Oct 3, 2011
Messages
22
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:

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
 
objBook.SaveAs strSheetFolder & strSheetFile,,,,, False

Okay, I got SaveAs to work, I was just being stupid. Apparently DoCmd.TransferSpreadsheet turns on "Always Create Backup", so if you just .Save it'll create a backup.
 

Users who are viewing this thread

Back
Top Bottom