in my vb project i have a number of data reports each using a different papersize. each time, b4 opening the report, the paper size has to be set in the printer dialogue box and then the report shows correctly. otherwise the messages like "report width larger than paper width" are seen. Isn't there a method to change the paper size through vb code so that there is no need to open printer properties again and again. The statements like "set printer.papersize=..." donot work.

thx.

Have you tried the actual printer page options as yet?

Look at the code below -

With Printer
    .PaperSize = vbPRPS10x14
End With

At .papersize, type vbprp and ctrl spacebar for intellisense. This will give you much more options than the original size coding stuff.

Hope this helps...

Have you tried the actual printer page options as yet?

Look at the code below -

With Printer
    .PaperSize = vbPRPS10x14
End With

At .papersize, type vbprp and ctrl spacebar for intellisense. This will give you much more options than the original size coding stuff.

Hope this helps...

sir,

when we use the code printer.papersize="...", it does not change the default printers settings, but can be used when printing directly from vb using printer object. however, datareport reads the paper size property from the defauult printer, which can be changed only through control panel to reflect it in datareport.
thx

I have used the following code below, making use of the default printer. It all worked fine for me, even from a datareport. If all your datareport controls is within bounds, you should not have a problem.

Private Sub Command1_Click()

CommonDialog1.PrinterDefault

With Printer
    .PaperSize = vbPRPSA4 'Using A4 size
    .Orientation = 2 'Landscape
End With
End Sub

'I have even changed to A3 size for a smaller report, all fine.
'Landscape was changed to 1 for portrait, also fine. 
'In your sample it seems that you are trying to give a size of paper yourself by using the quotation marks after
.Papersize = "" 'Rather use the preset options from vbPRP...

I hope this works for you. I will try and re-create your problem. So far no success, it all works fine.

thanks for the reply. I m not using "" in the papersize property but the value is selected from the availiable values of the drop down list. Why does not the datareport behave in the same way as an Access report?

Is your datareport the vb6 report with a rpt prefix? If yes, it comes with its own print option where the default printer dialog is loaded and the user can print by selecting ok etc.

u r very much right, but the default printer is availiable only after the report is displayed and if the width of the report is more than that specified in the printer, there is an eror message and no reecords are shown. we have to change settings in the control panel and then load the report again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.