473,659 Members | 3,592 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
intDriverVersio n 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
intDefaultSourc e 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(s trName 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_SwitchtoLeg al
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.OpenRepor t strName, acDesign ' Opens report in Design
view.
Set rpt = Reports(strName )
If Not IsNull(rpt.PrtD evMode) 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.intOrientati on ' Initialize
fields.
LSet DevString = DM ' Update property.
Mid(strDevModeE xtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
End If
DoCmd.SetWarnin gs False
DoCmd.Save acReport, strName
DoCmd.Close acReport, strName
DoCmd.SetWarnin gs True
DoCmd.Echo True, ""

Exit_SwitchtoLe gal:
Exit Sub

Err_SwitchtoLeg al:
DoCmd.Echo True, ""
Select Case Err
Case Else
msgbox Err & ":" & Err.Description , vbInformation + vbOKOnly,
"SwitchtoLe gal"
Resume Exit_SwitchtoLe gal
End Select
End Sub


Nov 12 '05 #1
5 7469
"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******** ************@ne wssvr28.news.pr odigy.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******** ************@co mcast.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(s trName As String)

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

Bob Q.
"Randy Harris" <ra***@SpamFree .com> wrote in message
news:Kd******** ************@ne wssvr28.news.pr odigy.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
intDriverVersio n 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
intDefaultSourc e 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(s trName 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_SwitchtoLeg al
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.OpenRepor t strName, acDesign ' Opens report in Design
view.
Set rpt = Reports(strName )
If Not IsNull(rpt.PrtD evMode) 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.intOrientati on ' Initialize
fields.
LSet DevString = DM ' Update property.
Mid(strDevModeE xtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
End If
DoCmd.SetWarnin gs False
DoCmd.Save acReport, strName
DoCmd.Close acReport, strName
DoCmd.SetWarnin gs True
DoCmd.Echo True, ""

Exit_SwitchtoLe gal:
Exit Sub

Err_SwitchtoLeg al:
DoCmd.Echo True, ""
Select Case Err
Case Else
msgbox Err & ":" & Err.Description , vbInformation + vbOKOnly,
"SwitchtoLe gal"
Resume Exit_SwitchtoLe gal
End Select
End Sub

Nov 12 '05 #5
Bob Quintal <bq******@gener ation.net> wrote in message news:<96******* *************** ********@news.t eranews.com>...
"Brian DSouza" <no****@nospam. net> wrote in
news:1d******** ************@co mcast.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(s trName 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 must first define a paper form with the size of the format. My application NEEDS to dinamically define the size of paper to use. Using some unmanaged code, it is possible to programatically define a new paper form. Is there any way of...
10
1946
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 than a more spread-out and usable design that uses some scrolling. Not surprisingly it's the work of paper-based magazine designers, not web designers. This leaves me with several conflicting requirements: - The body text size for the...
0
1745
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 paper size and sets the Paper Size to Letter. I'd like to hard code the Paper Size and Zoom to Fit for each type of report I have. Is this possible? Thank you.
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 know something must be different on the machines. But what? I have checked everything ! Thanks, Ira
0
1581
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 to know how to get manipulate that within my c# app. Manual selection is: "Print" select -> Paper/Quality (tab) then select -> Source Is: (ComboListBox) How can I do this in the following code? if(m_numberOfPages < 1)
1
2726
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 paper TYPE to PLAIN (on the printer itself)... I can get the output to the correct bin. However, I need the bottom bin to be exclusive to this app. I physically set the paper TYPE to LETTERHEAD, but I can not figure out how to set the PAPER...
4
2805
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 figure out this? I am using following code: Dim customPaperSize As New PaperSize("11x9", 1100, 900) pdMain.DefaultPageSettings.PaperSize = customPaperSize
6
12423
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 card is 79mm high and 210 mm large, and each card is on a paper with the same size, but I'm unable (don't know really how) to create a report to print out my cards as defined.
1
2102
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. I've created a report to print the labels. When I print (page 1 to 1 as I don't want to print all the records stored in the database) the
0
8428
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
8337
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
8851
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
8748
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
8531
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
4175
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
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
2
1739
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.