I have a query I want exported to Excel. I then want to format the Excel file for column width, font, font size, bolding, etc. I created the macro in Access 2007 to export the query and then open in Excel. I then converted the macro to VBA. No problems there. Tested and everything is working. In Excel I recorded a macro doing all the formatting changes I want.
This is where my confusion comes in. I am not sure what needs to be done in Access to automate the formatting from the Access side. I have searched the forum but most of the posts I see are trying to format the exported data and also accomplish something else. I am not sure what code is for the formatting and what code is for the other stuff.
Below is the VBA code to export the query to Excel:
Private Sub butExcelAllUsers_Click()
On Error GoTo butExcelAllUsers_Click_Err
DoCmd.OutputTo acOutputQuery, "qryMyTasksAllUsers-ForExcel", "Excel97-Excel2003Workbook(*.xls)", "", True, "", 0, acExportQualityPrint
butExcelAllUsers_Click_Exit:
Exit Sub
butExcelAllUsers_Click_Err:
MsgBox Error$
Resume butExcelAllUsers_Click_Exit
End Sub
Can you help me with the additional code needed to perform the formatting once the query has been exported? Like I said, I already have the Excel VBA code for all my formatting, I just need the Access code to make it work.
This is where my confusion comes in. I am not sure what needs to be done in Access to automate the formatting from the Access side. I have searched the forum but most of the posts I see are trying to format the exported data and also accomplish something else. I am not sure what code is for the formatting and what code is for the other stuff.
Below is the VBA code to export the query to Excel:
Private Sub butExcelAllUsers_Click()
On Error GoTo butExcelAllUsers_Click_Err
DoCmd.OutputTo acOutputQuery, "qryMyTasksAllUsers-ForExcel", "Excel97-Excel2003Workbook(*.xls)", "", True, "", 0, acExportQualityPrint
butExcelAllUsers_Click_Exit:
Exit Sub
butExcelAllUsers_Click_Err:
MsgBox Error$
Resume butExcelAllUsers_Click_Exit
End Sub
Can you help me with the additional code needed to perform the formatting once the query has been exported? Like I said, I already have the Excel VBA code for all my formatting, I just need the Access code to make it work.