我是 Access 和 VBA 的新手,并试图开发一个简单的代码:将表导出到 xls,打开它,简单的操作(格式化),保存并关闭。
但在此过程中我收到以下消息框:"A file named RESUME.XLW" already exists in this location. Do you want to replace it?"
选择“是”将生成 xls 文件。但是当我尝试打开它时,Excel 以只读模式运行,我不明白为什么。
我正在使用以下代码:
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
提前致谢!