C
chris
Hi everyone. Im trying to update a Word VB project which accesses an
Access database for various things (and the original programmer is no
longer available). project originally created in OfficeXP but now using
2003.
One section prints out a report including a number of fields matching
certain criteria using the following code;
Set acc = CreateObject("Access.application")
acc.opencurrentdatabase dba$
For tx = 0 To (cbogfile.ListCount - 2) \ 30
acc.DoCmd.OpenReport xreport$, 0, xreport$, tstring$(tx)
Next
acc.Quit
Thats fine, but I want to be able to export it to Word or Excel or some
other editable format instead of sending it straight to the printer.
xreport$ = "TMReport" so tried the following lines to replace the
DoCmd.OpenReport line;
acc.DoCmd.OpenReport "TMReport", acPreview, "", tstring$(tx)
acc.DoCmd.OutputTo acOutputReport, "TMReport", acCmdOutputToExcel,
"f:\Test.rtf"
which prints (why - shouldnt this just preview?) and then stops with
error 56 'application-defined or object-defined error' on the OutputTo
line. How do I fix this? I thought this would be simple and Im new to
programming - but after 3 days of looking without success thought I
would ask a group for help.
Thanks in advance
Chris
Access database for various things (and the original programmer is no
longer available). project originally created in OfficeXP but now using
2003.
One section prints out a report including a number of fields matching
certain criteria using the following code;
Set acc = CreateObject("Access.application")
acc.opencurrentdatabase dba$
For tx = 0 To (cbogfile.ListCount - 2) \ 30
acc.DoCmd.OpenReport xreport$, 0, xreport$, tstring$(tx)
Next
acc.Quit
Thats fine, but I want to be able to export it to Word or Excel or some
other editable format instead of sending it straight to the printer.
xreport$ = "TMReport" so tried the following lines to replace the
DoCmd.OpenReport line;
acc.DoCmd.OpenReport "TMReport", acPreview, "", tstring$(tx)
acc.DoCmd.OutputTo acOutputReport, "TMReport", acCmdOutputToExcel,
"f:\Test.rtf"
which prints (why - shouldnt this just preview?) and then stops with
error 56 'application-defined or object-defined error' on the OutputTo
line. How do I fix this? I thought this would be simple and Im new to
programming - but after 3 days of looking without success thought I
would ask a group for help.
Thanks in advance
Chris