Align Data Before Exporting to Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a query that I export to Excel using the OutputTo Function in a Macro.
The dataset contains columns of text, numbers, dates, etc. When opening the
spreadsheet after export, the columns are all mis-aligned (ie. some right
justified, some left, etc.). Is it possible in my query or macro programming
to control the alignment layout of these fields prior to exporting?
 
Hi Laura,

The alignment is controlled by Excel. As far as I know it uses the
"general" format: numbers and Excel date values are right-aligned within
the cells, and text is left-aligned. A column with mixed text and
numeric values will have mixed alignment accordingly (Excel ignores the
fact that it has a Text field type in Access).

You can force Excel to treate numeric values as text by having the query
prefix them with an apostrophe. Use a calculated field:

"'" & [MyField]

The apostrophes don't normally cause any problems in the Excel worksheet
- unless you have a formula that refers to the cell(s) in question and
expects a numeric value.
 
Back
Top