I am creating a VBA script that exports a table into several excel shared worksheets in a specific directory.
The problem is that Excel issues a warning to confirm the save of the file for each file.
I would like to delete this confirmation. Using VBA directly in excel macros you can do the following:
Application.DisplayAlerts = False
Does anyone know how to use the Application
object from the instance of this worksheet within Access or some other way to save this file?
Code snippet that generates the tiles:
Private Function formataPlanilha(path As String)
Dim workbook As Excel.workbook
Dim sheet As Excel.Worksheet
Set workbook = Excel.Application.Workbooks.Open(path)
If workbook.MultiUserEditing Then
workbook.ExclusiveAccess
workbook.Application.DisplayAlerts = False
End If
Set sheet = workbook.Sheets(1)
On Error GoTo ErrorHandler
With sheet
Call Formata_Planilha_Faltas
End With
workbook.Saved = True
workbook.SaveAs Filename:=path, AccessMode:=xlShared, ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges
ErrorHandler:
workbook.Close
End Function
Note: As the DoCmd.TransferSpreadsheet acExport
command does not save the exported file as shared, I have to reopen the worksheet in the excel object, apply some formatting, and save as shared.