Hi,
I have the following code that takes a query with lots of Brokers and creates an Excel file for each Broker.
Its largely copied from other code and tailored to work for my needs.
I am using Access 2007 to Office 2007.
What I would like to do extra is format each of the 350+ Excel files to auto-width the columns. Is their a template file I can use or additional code I can add to the above that will do this for me?
Thanks in advance for anything that you can offer.
I have the following code that takes a query with lots of Brokers and creates an Excel file for each Broker.
Code:
Private Sub Command0_Click()
Dim rs As DAO.Recordset
Dim sql As String
Dim strPath As String
strPath = "C:\Temp\"
sql = "SELECT DISTINCT Query.Broker FROM Query;"
Set rs = CurrentDb().OpenRecordset(sql, dbOpenSnapshot)
Do While Not rs.EOF
strBrokerCode = rs!Broker
DoCmd.OutputTo acOutputQuery, "Output", acFormatXLS, strPath & strBrokerCode & ".xls", False, "", 0, acExportQualityPrint
rs.MoveNext
Loop
Set rs = Nothing
End Sub
Its largely copied from other code and tailored to work for my needs.
I am using Access 2007 to Office 2007.
What I would like to do extra is format each of the 350+ Excel files to auto-width the columns. Is their a template file I can use or additional code I can add to the above that will do this for me?
Thanks in advance for anything that you can offer.