Michael Dean
asked on
Export Report to Excel
So I have a report that I want to export to Excel using the Wizard Access 2010 provides. But the font style and size are not being sent into the Excel file.
In other words, the font for a text box on the report is Ariel, but when the resulting Excel file is created the font is Verdana.
In other words, the font for a text box on the report is Ariel, but when the resulting Excel file is created the font is Verdana.
Are you looking to actually manipulate the exported data using Excel, or simply export it in a non-Access format?
If the latter, try exporting to PDF instead of Excel, which will keep the same layout.
If the latter, try exporting to PDF instead of Excel, which will keep the same layout.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
here is how to change the Excel font using Access code
sub changeXLFont()
dim xlObj
set xlObj = createObject("excel.applic ation")
xlObj.workbooks.open <path to excel file>
with xlObj
.worksheets(1).select
.activesheet.cells.select
.selection.font.Name = "Arial"
.selection.font.Size = 12
.activeworkbook.Save
end with
xlobj.quit
end sub
.
sub changeXLFont()
dim xlObj
set xlObj = createObject("excel.applic
xlObj.workbooks.open <path to excel file>
with xlObj
.worksheets(1).select
.activesheet.cells.select
.selection.font.Name = "Arial"
.selection.font.Size = 12
.activeworkbook.Save
end with
xlobj.quit
end sub
.
Your alternative is excel automation. See this example:
http://social.msdn.microsoft.com/Forums/office/en-US/adf2dc3f-d43e-451f-ad58-5617865b1e82/access-2007-using-vba-to-export-a-table-or-recordset-into-excel-2007
Automation basically opens Excel and gives you the same full control over the spreadsheet through VBA code that you would get working directly through Excel's user interface. The trade-off of course is that it can get very code intensive.
For something as minor as the font... I personally would live with the default font in the wizards export.