I'm quite new in Access and VBA and trying to develop a simple code: export a table to a xls, open it, simple manipulations(formatting), save and close.
But I'm getting the following message box during the process: "A file named RESUME.XLW" already exists in this location. Do you want to replace it?"
Choosing "Yes" will generate the xls file. But when I try to open it, the Excel runs in read only mode, and I don't understanding why.
I'm using the following code:
Sub FormataExcelPadrao(caminhoExcel As String)
Set arquivoExcel = CreateObject("Excel.Application")
arquivoExcel.Workbooks.Open (caminhoExcel)
With arquivoExcel
For Each pagina In .Worksheets
With pagina
.Columns("A:Z").Autofit
.Cells.Font.Size = "10"
.Cells.Font.Name = "Calibri"
End With
Next pagina
End With
arquivoExcel.Save
arquivoExcel.Close
End Sub
Thanks in advance!