MS Access VBA Automation – Excel Font setzen und Autofit

Sub FormatExcel(pathFilename As String)

On Error GoTo FormatExcel_Error

Dim objExcel As Object
Set objExcel = CreateObject(„Excel.Application“)
objExcel.Visible = True
objExcel.DisplayAlerts = False

Dim objWorkbook As Workbook
Set objWorkbook = objExcel.Workbooks.Open(pathFilename)
Dim objWorksheet As Worksheet
Set objWorksheet = objWorkbook.Worksheets(1)

objWorksheet.Cells.Select
objWorksheet.Cells.Font.NAME = „Tahoma“
objWorksheet.Cells.Font.Size = 10
objWorksheet.Columns.AutoFit
objWorksheet.Cells(1, 1).Select

objWorkbook.Save
‚objExcel.Quit

Exit Sub

FormatExcel_Error:
MsgBox Err.Description
End Sub