Hi Chris,
Exporting reports is often very troublesome. If the layout is what
matters most, you can
-use Snapshot format (which may require people to install the free
Snapshot viewer)
-print the report to PDF (using Acrobat Distiller or another PDF-maker
such as CutePDF).
-use the Report Utilities from
www.lebans.com
Unfortunately the standard export routine doesn't allow one to use an
Excel template (life would be much easier if they did). For phone
numbers, try prepending an apostrophe, e.g. by using a calculated field
in the query that provides data to the report, e.g.
fPhone: "'" & [Phone]
The apostrophe should force Excel to treat the field as text and not a
number. For dates, I suppose you could try the same trick, e.g.
fTheDate: "'" & Format([TheDate], "dd mmm yyyy")
but I'm really not sure what other options might exist.
On 7 May 2006 08:45:50 -0700,
(E-Mail Removed) wrote:
>Hi John
>Ok I found and added the Reference to Access under the Tools menu, and
>that solved the error. Thanks for that - looks like it was something
>fairly simple after all!
>
>And by using the Where condition associated with acViewPreview on the
>line before the acOutputReport line, I can limit the number of records
>output (so that 60 of 5000+ are output to the XLS file). This is the
>code I have now:
>
>Set acc = CreateObject("Access.application")
> acc.opencurrentdatabase dba$
> temptext = ""
> For tx = 0 To (cbogfile.ListCount - 2) \ 30
> If tx = 0 Then
> temptext = tstring$(tx)
> Else
> temptext = temptext + "OR" + tstring$(tx)
> End If
> Next
> acc.DoCmd.OpenReport xreport$, acViewPreview, xreport$, temptext
> acc.DoCmd.OutputTo acOutputReport, xreport$, acFormatXLS, "F:\" +
>xreport$ + Format$(Now, "ddmmyy") + ".xls"
>acc.quit
>
>However, this doesnt keep the formatting of the Access Report (when
>printed) - so phone numbers lose the leading 0, dates get converted
>into the internal Excel 5-digit number, etc.
>I've tried using acFormatRTF which preserves the formatting set within
>the design view of the Access Report (as far as I can tell) - but
>annoyingly wordwraps some of the fields which throws the page numbering
>out.
>
>Is there any way of controlling the format of the resulting Excel file
>- such as using some form of preformatted xls template?
>
>Chris
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.