Changing printer preference using vb6

printingvb6

I am having a problem when my program is installed to another computer, where its printer preference is different, where my data report accepts Letter size 8.2 * 11 in, because when the printer preference is different the data report well not show and gives an error saying the page width is larger than paper width, does anyone know how to fix this problem.

i tried this code but it didn't work

Printer.PaperSize = vbPRPSLetter

Best Answer

Check out the Microsoft KnowledgeBase article FIX: Error Message "Report Width Is Larger Than the Paper Width" When Showing Data Report in Landscape

When using the Show method of Data Report to preview the report, the page orientation defaults to the default printer settings on the local computer. Therefore, if the orientation of the default printer settings is set to Portrait of standard Letter paper and your report width is more than 8.5 inches wide, the following error occurs: Report Width is Larger than the Paper Width.

The solution appears to be setting Orientation before using the Data Report. Change DataReport1 to the name of your data report.

DataReport1.Orientation = rptOrientLandscape
DataReport1.Show

EDIT Another suggestion: Microsoft offer a free DLL that allows you to change the default settings for the printer. You could try using that free DLL in your project, then do something like this code below before using the data report. Microsoft say "this DLL is particularly useful when dealing with the Data Report, which reads the default printer orientation prior to displaying or printing a report."

  Set obj = New PrinterControl
  obj.ChngOrientationLandscape
Related Topic