I am trying to export an access report i had created with the exportwithformatting macro; the problem is the export happens but the excel file that it exports into does not seem to keep the column formatting from my query.
I framed a code but am still having issues: any suggestions on the below code is greatly appreciated.
Expand|Select|Wrap|Line Numbers
- Public Sub Workbook_receiveRCFormats()
- Dim acOutputReport As Object
- Dim acTableRow As Object
- Dim acOutputReport As String
- Dim xlFileName As String
- Dim acFormat As acFormat
- Dim Index As Long
- Dim NoItems As Long
- Dim I As Long
- Set acContainer = ThisWorkbook.Container
- Set acReport = acContainer.Reports("RC_FORMATS").Report
- For Each acReportRow In acReport.Rows
- Index = acReportRow("INDEX")
- NoItems = acRCFormats.Count
- If Index <= NoItems Then
- Set acRCFormat = acRCFormats.Item(Index)
- Else
- For I = NoItems + 1 To Index
- Set acRCFormat = New acRCFormat
- acRCFormats.Add acRCFormat
- Next I
- End If
- acRCFormat.setFormat acReportRow
- Next acReportRow
- acOutReportData = "rpt-FINANCE"
- xlFileName = "C:\Documents and Settings.xls"
- DoCmd.OutputTo acOutputReport, outReportData, acFormatXLS, xlFileName
- End Sub
Frank