By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,630 Members | 1,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,630 IT Pros & Developers. It's quick & easy.

Stephen Lebans' ReportUtilities - error in my adaption

P: n/a
I am trying to adapt Lebans' ReportUtilities to export reports (to
preserve formatting) from an Access 97 application. I have made the
reference to his mde and copied the modules into my db. I have
created a custom toolbar with a custom control, "Export to File". In
the On Action property (of the export control) I inserted the code
"pf.ExportToMSWord rptApplicantReferral" which I had copied from his
sample db except for the name of my report. When I run the report and
attempt to export it I receive the error "...can't run the macro or
callback function 'pf.ExportToMSWord rptApplicantReferral'. Make sure
the macro or function exists and takes the correct parameters." I was
trying to get just one report exporting before trying to code the
toolbar control to respond to whatever report was open at the time. I
would appreciate any assistance in figuring out how to code this such
that the user could from the PrintPreview mode of the report choose to
print a hardcopy or export it to a Word document.

Thanks,
Alex
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You cannot call a method of a Class as you are trying to do from the On
Action prop. Insteaad create a function that:

Creates the instance of the ReportUtilites class
Calls the ExportToMSWord method
Deletes the instance of the ReportUtilities class

Basically, all of the setup code you see behind the sample form you need
to palce behind a Public function contained within a standard Code
module(not a Form's class module!)

Le tme know how you make out. I would like to post the finished code to
my site as it is a good idea.
:-)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Alex Wisnoski" <Al***********@ncmail.net> wrote in message
news:5c**************************@posting.google.c om...
I am trying to adapt Lebans' ReportUtilities to export reports (to
preserve formatting) from an Access 97 application. I have made the
reference to his mde and copied the modules into my db. I have
created a custom toolbar with a custom control, "Export to File". In
the On Action property (of the export control) I inserted the code
"pf.ExportToMSWord rptApplicantReferral" which I had copied from his
sample db except for the name of my report. When I run the report and
attempt to export it I receive the error "...can't run the macro or
callback function 'pf.ExportToMSWord rptApplicantReferral'. Make sure
the macro or function exists and takes the correct parameters." I was
trying to get just one report exporting before trying to code the
toolbar control to respond to whatever report was open at the time. I
would appreciate any assistance in figuring out how to code this such
that the user could from the PrintPreview mode of the report choose to
print a hardcopy or export it to a Word document.

Thanks,
Alex


Nov 12 '05 #2

P: n/a
Thank you for your quick response to my request for help. I did like
you said and created the following function:
Function Exporttofile()
Set pf = New clsPrintToFit
pf.ExportToMSWord stDocName
Set pf = Nothing
End Function
I set the OnAction property of my Export control to the function
"=Exporttofile()". After running my test report, I clicked on my
Export control and everything seemed to work fine; I was prompted for
a name and location of the file to be saved. When I opened the saved
file the data was there but all the lines that separate the fields and
records were absent. I knew I must be leaving out some of your key
code so I looked back thru your sample and saw the lines in the report
dealing with the class clsPrintLines. I inserted those lines in my
report but began getting "Compile error: User-defined type not
defined." on the variable "pl =" in the phrase "Set pl =". Here is my
code:

Option Compare Database
Option Explicit
Dim strPriority As String
' Stephen Lebans
' Copyright Lebans Holdings 1999 Ltd.
' St*****@lebans.com
' www.lebans.com
' Declare an object of Type PrintLine Class
Dim pl As clsPrintLines

Private Sub Report_Close()
' Cleanup Stephen Lebans
Set pl = Nothing
DoCmd.Close acForm, "frmPositionNumDialog", acSaveNo
End Sub

Private Sub Report_Open(Cancel As Integer)
' Create the instance of our Class Stephen Lebans
Set pl = New clsPrintLines
' Init the Class Stephen Lebans
pl.InitSections Me

' For Demonstration purposes Stephen Lebans
' Turn on Borders and Vertical Lines
' for every Section on the Report.
pl.ResetToDefaults

DoCmd.Maximize
End Sub

I do have the module "clsPrintLines" in the database and the variable
pl is defined in the approriate location. Would you have any
suggestions as to what is causing this?
Thank you for your help,
Alex
"Stephen Lebans" <Fo****************************************@linval id.com> wrote in message news:<Ke*********************@ursa-nb00s0.nbnet.nb.ca>...
You cannot call a method of a Class as you are trying to do from the On
Action prop. Insteaad create a function that:

Creates the instance of the ReportUtilites class
Calls the ExportToMSWord method
Deletes the instance of the ReportUtilities class

Basically, all of the setup code you see behind the sample form you need
to palce behind a Public function contained within a standard Code
module(not a Form's class module!)

Le tme know how you make out. I would like to post the finished code to
my site as it is a good idea.
:-)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Alex Wisnoski" <Al***********@ncmail.net> wrote in message
news:5c**************************@posting.google.c om...
I am trying to adapt Lebans' ReportUtilities to export reports (to
preserve formatting) from an Access 97 application. I have made the
reference to his mde and copied the modules into my db. I have
created a custom toolbar with a custom control, "Export to File". In
the On Action property (of the export control) I inserted the code
"pf.ExportToMSWord rptApplicantReferral" which I had copied from his
sample db except for the name of my report. When I run the report and
attempt to export it I receive the error "...can't run the macro or
callback function 'pf.ExportToMSWord rptApplicantReferral'. Make sure
the macro or function exists and takes the correct parameters." I was
trying to get just one report exporting before trying to code the
toolbar control to respond to whatever report was open at the time. I
would appreciate any assistance in figuring out how to code this such
that the user could from the PrintPreview mode of the report choose to
print a hardcopy or export it to a Word document.

Thanks,
Alex

Nov 12 '05 #3

P: n/a
On 6 May 2004 08:30:54 -0700, Al***********@ncmail.net (Alex Wisnoski) wrote:

It is mentioned in Stephen's notes that come with ReportUtilities that due to a bug in Access, lines will not export correctly. Replace all your
straight lines with rectangles set to 0 height and they will export and display correctly.

Thank you for your quick response to my request for help. I did like
you said and created the following function:
Function Exporttofile()
Set pf = New clsPrintToFit
pf.ExportToMSWord stDocName
Set pf = Nothing
End Function
I set the OnAction property of my Export control to the function
"=Exporttofile()". After running my test report, I clicked on my
Export control and everything seemed to work fine; I was prompted for
a name and location of the file to be saved. When I opened the saved
file the data was there but all the lines that separate the fields and
records were absent.

Wayne Gillespie
Gosford NSW Australia
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.