473,503 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Controlling Paper Size

I got the following code from an earlier posting (much earlier, like 1999)
in this ng. This is supposed to control the paper size selected to legal,
even if the default printer changes. Question is where do I stick this code,
so that my calling function can see it? In the form from which I print the
report?

TIA.

Brian
Option Compare Database
Option Explicit

Type gtypStr_DEVMODE
RGB As String * 94
End Type

Type gType_DEVMODE
strDeviceName As String * 16
intSpecVersion As Integer
intDriverVersion As Integer
intSize As Integer
intDriverExtra As Integer
lngFields As Long
intOrientation As Integer
intPaperSize As Integer
intPaperLength As Integer
intPaperWidth As Integer
intScale As Integer
intCopies As Integer
intDefaultSource As Integer
intPrintQuality As Integer
intColor As Integer

intDuplex As Integer
intResolution As Integer
intTTOption As Integer
intCollate As Integer
StrFormName As String * 16
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type
Sub SwitchtoLegal(strName As String)
' Comments : Switches paper size to legal, regardless of original
setting
' Parameters : strName - contains the name of the report
' Returns : Saves report with new legal setting. User needs mod perm
' Created : Received from Brian Ward, 3/12/1999
' Modified : Kim Jacobson 3/12/1999
'
' --------------------------------------------------------
'Call the procedure like this:

' Dim strDocName As String

' strDocName = "Report Name Here"
' SwitchtoLegal (strDocName)

' --------------------------------------------------------
On Error GoTo Err_SwitchtoLegal
Dim DevString As gtypStr_DEVMODE
Dim DM As gType_DEVMODE
Dim strDevModeExtra As String
Dim rpt As Report
DoCmd.Echo False, "Checking default printer settings..."
DoCmd.OpenReport strName, acDesign ' Opens report in Design
view.
Set rpt = Reports(strName)
If Not IsNull(rpt.PrtDevMode) Then
strDevModeExtra = rpt.PrtDevMode
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.intPaperSize = 5 'set to legal, standard would be 1
'DM.lngFields = DM.lngFields Or DM.intOrientation ' Initialize
fields.
LSet DevString = DM ' Update property.
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
End If
DoCmd.SetWarnings False
DoCmd.Save acReport, strName
DoCmd.Close acReport, strName
DoCmd.SetWarnings True
DoCmd.Echo True, ""

Exit_SwitchtoLegal:
Exit Sub

Err_SwitchtoLegal:
DoCmd.Echo True, ""
Select Case Err
Case Else
msgbox Err & ":" & Err.Description, vbInformation + vbOKOnly,
"SwitchtoLegal"
Resume Exit_SwitchtoLegal
End Select
End Sub


Nov 12 '05 #1
5 7458
"Brian DSouza" <no****@nospam.net> wrote in message
news:-J********************@comcast.com...
I got the following code from an earlier posting (much earlier, like 1999)
in this ng. This is supposed to control the paper size selected to legal,
even if the default printer changes. Question is where do I stick this code, so that my calling function can see it? In the form from which I print the
report?

TIA.

Brian
Brian, you could put it in the module for the form, but that probably
wouldn't be the best place for it. In the future you might wish to open the
report elsewhere, or you might wish to use the same procedure for another
report. It would probably be better to simply put it into a standard module
(the module name doesn't matter). Simply call the routine from the form, as
shown in the example provided with the code.
' strDocName = "Report Name Here"
' SwitchtoLegal (strDocName)


Nov 12 '05 #2
That is what I thought. I stuck it in a module I call Globals, where I also
declare variables that I use for "global" system state information. I got
some kind of error message like.

"Function not defined."

and in the debug window:

<highlighted> SwitchtoLegal </highlighted>

I have made absolutely sure that the spelling is the same.

"Randy Harris" <ra***@SpamFree.com> wrote in message
news:Kd********************@newssvr28.news.prodigy .com...
"Brian DSouza" <no****@nospam.net> wrote in message
news:-J********************@comcast.com...
I got the following code from an earlier posting (much earlier, like 1999) in this ng. This is supposed to control the paper size selected to legal, even if the default printer changes. Question is where do I stick this code,
so that my calling function can see it? In the form from which I print the report?

TIA.

Brian


Brian, you could put it in the module for the form, but that probably
wouldn't be the best place for it. In the future you might wish to open

the report elsewhere, or you might wish to use the same procedure for another
report. It would probably be better to simply put it into a standard module (the module name doesn't matter). Simply call the routine from the form, as shown in the example provided with the code.
' strDocName = "Report Name Here"
' SwitchtoLegal (strDocName)


Nov 12 '05 #3
"Brian DSouza" <no****@nospam.net> wrote in
news:1d********************@comcast.com:
That is what I thought. I stuck it in a module I call
Globals, where I also declare variables that I use for
"global" system state information. I got some kind of error
message like.

"Function not defined."

and in the debug window:

<highlighted> SwitchtoLegal </highlighted>

I have made absolutely sure that the spelling is the same.
In the module created find the line:
Sub SwitchtoLegal(strName As String)

Put the word public before it, eg Public Sub.....

Bob Q.
"Randy Harris" <ra***@SpamFree.com> wrote in message
news:Kd********************@newssvr28.news.prodigy .com...
"Brian DSouza" <no****@nospam.net> wrote in message
news:-J********************@comcast.com...
> I got the following code from an earlier posting (much
> earlier, like 1999) > in this ng. This is supposed to control the paper size
> selected to legal, > even if the default printer changes. Question is where do I
> stick this

code,
> so that my calling function can see it? In the form from
> which I print the > report?
>
> TIA.
>
> Brian


Brian, you could put it in the module for the form, but that
probably wouldn't be the best place for it. In the future
you might wish to open

the
report elsewhere, or you might wish to use the same
procedure for another report. It would probably be better to
simply put it into a standard

module
(the module name doesn't matter). Simply call the routine
from the form,

as
shown in the example provided with the code.
> ' strDocName = "Report Name Here"
> ' SwitchtoLegal (strDocName)




Nov 12 '05 #4
Hi Brian,

This code appears to be essentially the same as that shown in a Microsoft KB article:

"ACC2000: How to Build a Visual Basic Module to Print a Report in Landscape Mode on
Legal-Size Paper"
http://support.microsoft.com/default.aspx?scid=kb;[LN];302416

I copied the code you included into a new module in the sample Northwind database. Then I
entered the following command into the debug window:

SwitchtoLegal("Alphabetical List of Products")

It works fine *most* of the time. However, sometimes I am receiving error # 29068, which
reads:
"Microsoft Access cannot complete this operation.
You must stop the code and try again".

When I stepped through the procedure line-by-line, I find that on those times when I get
the error, it consistently occurs on the line of code that reads:

DoCmd.Save acReport, strName

I'm kind of stumped as to why this error is not consistent--it's rearing its ugly head
just every so often.
Tom

____________________________________________

"Brian DSouza" <no****@nospam.net> wrote in message
news:-J********************@comcast.com...
I got the following code from an earlier posting (much earlier, like 1999)
in this ng. This is supposed to control the paper size selected to legal,
even if the default printer changes. Question is where do I stick this code,
so that my calling function can see it? In the form from which I print the
report?

TIA.

Brian
Option Compare Database
Option Explicit

Type gtypStr_DEVMODE
RGB As String * 94
End Type

Type gType_DEVMODE
strDeviceName As String * 16
intSpecVersion As Integer
intDriverVersion As Integer
intSize As Integer
intDriverExtra As Integer
lngFields As Long
intOrientation As Integer
intPaperSize As Integer
intPaperLength As Integer
intPaperWidth As Integer
intScale As Integer
intCopies As Integer
intDefaultSource As Integer
intPrintQuality As Integer
intColor As Integer

intDuplex As Integer
intResolution As Integer
intTTOption As Integer
intCollate As Integer
StrFormName As String * 16
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type
Sub SwitchtoLegal(strName As String)
' Comments : Switches paper size to legal, regardless of original
setting
' Parameters : strName - contains the name of the report
' Returns : Saves report with new legal setting. User needs mod perm
' Created : Received from Brian Ward, 3/12/1999
' Modified : Kim Jacobson 3/12/1999
'
' --------------------------------------------------------
'Call the procedure like this:

' Dim strDocName As String

' strDocName = "Report Name Here"
' SwitchtoLegal (strDocName)

' --------------------------------------------------------
On Error GoTo Err_SwitchtoLegal
Dim DevString As gtypStr_DEVMODE
Dim DM As gType_DEVMODE
Dim strDevModeExtra As String
Dim rpt As Report
DoCmd.Echo False, "Checking default printer settings..."
DoCmd.OpenReport strName, acDesign ' Opens report in Design
view.
Set rpt = Reports(strName)
If Not IsNull(rpt.PrtDevMode) Then
strDevModeExtra = rpt.PrtDevMode
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.intPaperSize = 5 'set to legal, standard would be 1
'DM.lngFields = DM.lngFields Or DM.intOrientation ' Initialize
fields.
LSet DevString = DM ' Update property.
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
End If
DoCmd.SetWarnings False
DoCmd.Save acReport, strName
DoCmd.Close acReport, strName
DoCmd.SetWarnings True
DoCmd.Echo True, ""

Exit_SwitchtoLegal:
Exit Sub

Err_SwitchtoLegal:
DoCmd.Echo True, ""
Select Case Err
Case Else
msgbox Err & ":" & Err.Description, vbInformation + vbOKOnly,
"SwitchtoLegal"
Resume Exit_SwitchtoLegal
End Select
End Sub

Nov 12 '05 #5
Bob Quintal <bq******@generation.net> wrote in message news:<96******************************@news.terane ws.com>...
"Brian DSouza" <no****@nospam.net> wrote in
news:1d********************@comcast.com:
That is what I thought. I stuck it in a module I call
Globals, where I also declare variables that I use for
"global" system state information. I got some kind of error
message like.

"Function not defined."

and in the debug window:

<highlighted> SwitchtoLegal </highlighted>

I have made absolutely sure that the spelling is the same.

In the module created find the line:
Sub SwitchtoLegal(strName As String)

Put the word public before it, eg Public Sub.....

Bob Q.


Thanks Bob, but I did that too, actually. Same error message. Very
strange. Any other ideas.
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
346
by: Carlos Kirkconnell | last post by:
When printing, there is a definition for a Custom paper size, the custom paper size can be setted programatically and everything is supposed to work normally. But in windows 2000 and xp, the user...
10
1932
by: Andy Dingley | last post by:
I have a large commercial site to rebuild, where the design has been produced by the pixel-counting method. It's also one of those sites where cramming every space full of content is seen as better...
0
1730
by: Todd | last post by:
I have a mix of reports that are designed to print on either legal or letter size paper. When a legal sized report is first viewed in Print Preview, Page Setup uses the default Window printer's...
5
556
by: Ira S | last post by:
I use a DYMO labelwriter with my Access 97 database. I just purchased a new computer and in the report section under page setup/paper size, the new computer keeps changing the size automatically. I...
0
1575
by: trint | last post by:
Since we have a laserjet 4350tn with 4 paper trays, the .dll from hp of course adds to to funtionality (like being able to select a paper tray under one of the tabs) to the "Print" dialog. I want...
1
2716
by: Vince | last post by:
Through VB6 I asm trying to print to the bottom bin with a paper type of LetterHead on an HP4200tn printer. After much messing around with my bin issue, I finally determined that if I keep the...
4
2795
by: Sukh | last post by:
Hi, I am tring to change the paper size from default to custom paper size. In print preview its showing my custom size but when I print it print on default paper size. Can any one help me to...
6
12409
by: Brewtzaff | last post by:
Hello, I have a little problem to print my reports on custom sized paper. I got a db containing clubmembers, a query which selects only the needed infos to print out my membershipcards. My...
1
2093
by: Thorben Grosser | last post by:
Hello newsgroup, I'm finally done with my folder-archiving tool, still there are some flaws. To label the folders, I use a Dymo LabelWriter 400 printer which works great for my purposes. ...
0
7202
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,...
0
7280
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,...
0
7332
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...
1
6991
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...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.