Align Data Before Exporting to Excel

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?
 
J

John Nurick

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top