473,599 Members | 3,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stephen Lebans' ReportUtilities - error in my adaption

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.ExportToMSW ord rptApplicantRef erral" 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.ExportToMSW ord rptApplicantRef erral'. 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
3 2598
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.goo gle.com...
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.ExportToMSW ord rptApplicantRef erral" 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.ExportToMSW ord rptApplicantRef erral'. 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
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.ExportToMSWo rd 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, "frmPositionNum Dialog", acSaveNo
End Sub

Private Sub Report_Open(Can cel 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.ResetToDefau lts

DoCmd.Maximize
End Sub

I do have the module "clsPrintLi nes" 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************ *************** *************@l invalid.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.goo gle.com...
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.ExportToMSW ord rptApplicantRef erral" 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.ExportToMSW ord rptApplicantRef erral'. 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
On 6 May 2004 08:30:54 -0700, Al***********@n cmail.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.ExportToMSWo rd 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2488
by: Wally | last post by:
Hi All, I'm using Stephan Lebans' nifty code for automatically resizing text fields to the size required to show (almost) all text in that field (CanGrow3, thanks Stephen!). In general this function works great. However, I sometimes have a problem with the last text line. Often the last line is just below the end of the field and to view that line I have to scroll to it. Is that a known problem? And is there a solution?
11
3614
by: Patrick | last post by:
I am using Stephans code to change the background color of the Access container in Access 97, the code works fine when running in Access in the normal way. The problem occurs when running the program after creating a RunTime version when a gray rectangle appears at the top left hand side of the screen. This effect is present when using the sub that changes the color and when using the sub that calls up an image.
1
3095
by: Alex | last post by:
The JustiDirect text justification on Stephen LeBans site works well but I cannot get it to work on a sub report. Could anyone tell me if this is possible. Thanks. Alex
1
1839
by: ChrisR | last post by:
Hi Stephen Lebans Thank you very much for your effort and time you have spent writing and helping small hacks like me. I have just one problem with your mousewheelhook. I'm using Access 2002. I have db with an unbounded Main Form with numerous sub forms. The mousewheelhook works find with the subforms in the Main Form. Mousewheelhook is loaded in the Main Form Load event and unloaded in the same form in the unloaded event. The problem...
4
2157
by: Karl Roes | last post by:
Hi Stephen, Very Cool. I can only get it working on the first row of a continuous form. Is this correct? Regards Karl
3
3302
by: Phil Stanton | last post by:
I am trying to produce a program that will output any Access report to an editable Word document. So far it is working well but slowly with text boxes, labels, and lines. I now need to try to output one of Stephen Lebans' RTF2 controls on the report. He indicates that a copy and paste method will work from a form to the Word doc and that is fine although I have not done this in VB, rather used ^C and ^V I suspect that a similar method...
3
5811
by: Rémi | last post by:
Hello all! I've been using Stephen Lebans' MouseWheel stuff for a number of years now, without problems. I've used on different combinations of Access and Windows, and have had great results with it. (Even better, considering what I paid for it.) Just hit a situation where it didn't work, though, and I was wondering if anyone else has hit this yet: *A dumb terminal, running Windows 2003.
8
5469
by: grant | last post by:
Hi I've copied Stephens code into my db, and can get it to work, but only on "plain Jane" reports with no images. Most of my reports has an unbound image obluect in them that I set to an external image file using on_open code I've searched through this group and there are a few comments about snapshots not working with embedded images, and my testing seems to
3
1648
by: MLH | last post by:
I use Stephen Lebans modReportToPDF. In it is a function declared as Boolean. Inside the FN, there's a line assigning the FN name a value that's not True and not False. I'm thinking that's an oversight so I changed it from "" to False. Just wanna make sure there's not some support of the use of the ZLS value. Public Function ConvertReportToPDF( ... ) As Boolean .... If Len(RptName & vbNullString) = 0 Then
0
7992
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8398
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8400
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8051
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8267
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
3940
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2414
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1505
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.