Function ExportWFormatting()
nme = Format(Now, "mmddhhnnss")
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "PrevMonthQ", "\\rhino\users\Common\Manufacturing Machines\OEE\DTreports\" & nme & ".xlsx", True
Call ModifyExportedExcelFileFormats("\\rhino\users\Common\Manufacturing Machines\OEE\DTreports\" & nme & ".xlsx", "DTReport")
Public Sub ModifyExportedExcelFileFormats(sFile As String, sSheet As String)
On Error GoTo Proc_Error
Dim xlApp As Object
Dim xlSheet As Object
Set xlApp = CreateObject("Excel.Application")
Set xlSheet = xlApp.Workbooks.Open(sFile).Sheets(1)
With xlApp
.Application.Sheets(sSheet).Select
.Application.Rows("1:1").Select
.Application.Selection.Font.Bold = True
.Application.Range("A1").Select
.Application.Selection.AutoFilter
.Application.Cells.Select
.Application.Selection.Columns.AutoFit
.Application.Range("A1").Select
.Application.ActiveWorkbook.Save
.Application.ActiveWorkbook.Close
.Quit
End With
Exit_Proc:
Set xlApp = Nothing
Set xlSheet = Nothing
Exit Function
End Function