Link to home
Start Free TrialLog in
Avatar of Michael Dean
Michael DeanFlag for United States of America

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.
Avatar of mbizup
mbizup
Flag of Kazakhstan image

The export wizard is very rudimentary... you have no control over the format of the excel file.

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.
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.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
here is how to change the Excel font using Access code


sub changeXLFont()
dim xlObj
set xlObj = createObject("excel.application")
    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





.