Replace printer driver / SaveAsText / LoadFromText

G

Guest

I have some reports that do not open correctly with certain HP LaserJet PCL6
drivers (4060 and 2200 at least). They open apparentlly zoomed but actually
print across 10 pages instead of 1.

Per Microsoft, this is due to some problems with those particular drivers;
however, I can resolve the issue for a report by recreating the report while
the default printer is set to Generic / Text Only. According to Microsoft,
that driver is generic enough to avoid the conflict with the affected HP
printer drivers. I believe I created the original reports using default
printer Adobe PDF, and it must contain information that conflicts with the HP
PCL6 printer drivers.

However, re-creating 30+ reports manually is extremely tedious and
error-prone, since I must create a blank report, reset all properties to
match the original report, then copy/paste all controls and code from the
original to the copy.

I tried SaveAsText & LoadFromText. However, SaveAsText includes the the
printer driver information as well, presumably in the PrtMip, PrtDevMode, &
PrtDevNames hex code sections. I then created a blank report using the
generic printer, did a SaveAsText, and attempted to replace the errant print
driver section of my original report's text file with the generic one, but I
cannot now LoadFromText the corrected text file. I believe the CheckSum of
the text file prevents this.

Now, if Microsoft would just release the checksum calculation algorithm to
me, I could recalculate & manually edit the CheckSum in the LoadFromText, and
I think I would have it made, but I'm not holding my breath waiting for
Microsoft to release that...

I really don't want to just tell my clients that my app just has a problem
with certain HP printer drivers, when these are so common, they never see
such a problem with any other applications, and the problem can be solved by
recreating the report while using a more generic default printer.

Any ideas on how to replace the printer driver for a report with another one
without re-creating the report from scratch?
 
G

Geoff

Brian: As you know, when a report prints over more pages than it's supposed
to, it's usually because the design surface is greater than the printable
area for the printer being used. When you switch to the printer driver(s)
that cause this problem, do you find that their minimum margins (top,
bottom, left and right) are larger than the minimum margins of the printer
for which the reports were designed (ie the printable area is smaller
therefore the report has to be printed on multiple pages)? I don't suppose
that is the problem because your one page report is expanding to 10 pages,
which seems a lot. But if that is the case, could you do a once-and-for-all
redesign job using the driver with the largest minimum margins, ie with the
minimum printable area? You can find out what the minimum print margins are
by setting the margins to zero and Access will readjust them to the minimum
permitted by the printer.

Geoff.
 
G

Guest

I already tried reducing the report enough to allow a margin of an inch on
each side, which did not help. I have found that if a user previews the
report (so that it shows up in its oversized format), then switches from
landscape to portrait and back again, the report will display correctly (with
no margin changes) for that user & printer until the user opens it again with
a different default printer and then switches back to the HP PCL 6 default
printer.

My immediate solution was to switch to the PS driver for the users, and it
resolved the issue, but I am still looking for a way to correct the Access
part of the underlying problem by importing/changing (programmatically) the
printer driver info stored with the report when it is created.
 
G

Geoff

Brian:

Have you seen the DevMode class in the Access Developers Handbook
(Volume 1)? Here's the first paragraph of the explanation:

"The DevMode class makes it simple for you to work with printer-specific
properties of objects in Access (that is, it hides the complexities of
working with the PrtDevMode property). The class provides a group of
properties that map directly to elements of the Windows API DEVMODE
structure and to the PrtDevMode property of forms and reports."

I don't know if this would help you as this is my current reading. But for
further info:

http://www.developershandbook.com/

Geoff
 
G

Guest

Thank you.

I was not aware of the DevMode class info, but in my contact with Microsoft,
I actually got some info on how to copy the PrtDev info from one report to
another, since both PrtDevMode & PrtDevNames are properties of reports. Here
was my solution:

Create a report called ZFixPrtDev while having a known good printer (other
than Adobe PDF, which was part of the problem) as the default.

Create a query called ZFixPrtDev that selects the reports names. Here is the
SQL:

SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Type)=-32764));

Create and run a new module called ZFixPrtDev having this function:

Function FixPrtDev()

DoCmd.OpenReport "ZFixPrtDev", acViewDesign, , , acHidden
Dim rsReports As DAO.Recordset
Dim rptCount As Integer
Dim rptName As String
Set rsReports = CurrentDb.OpenRecordset("ZFixPrtDev", dbOpenSnapshot)
rsReports.MoveLast 'force accurate record count
rptCount = rsReports.RecordCount
rsReports.MoveFirst 'return to first record to begin loop
Do While Not rsReports.EOF
rptName = rsReports.Fields("Name").Value
If rptName <> "ZFixPrtDev" Then
DoCmd.OpenReport rptName, acViewDesign, , , acHidden
Reports(1).PrtDevMode = Reports!ZFixPrtDev.PrtDevMode
Reports(1).PrtDevNames = Reports!ZFixPrtDev.PrtDevNames
DoCmd.Close acReport, rptName, acSaveYes
End If
'go to next report
rsReports.MoveNext
Loop ' process next report
DoCmd.Close acReport, "ZFixPrtDev", acSaveNo
rsReports.Close
End Function

This function simply loops through all reports except ZFixPrtDev and sets
the PrtDevMode & PrtDevNames properties of each report to match that of
ZFixPrtDev. When done, I had to go back and set the page orientation & size
of each Portrait and Landscape/Legal report, since the ZFixPrtDev report was
Landscape/Letter.
 
G

Geoff

Brian,

Very, very neat. Many thanks for sharing the solution.

I've not seen a loop through reports (or other Access objects) done like
that before. I had envisioned you'd be using the DAO reports container or
the CurrentProject.AllReports collection, iterating through all the reports,
pointing the DevMode class to each report in turn, and calling the class's
properties and methods to fix things. But your way is smarter. Definitely
a solution for the library. When you see quality stuff like this, it makes
participating in newsgroups worthwhile.

Glad you got it solved.
Geoff
 

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