locked
Problem setting paper size in crystal report reports i m using some posted on RRS feed

  • Question


  •  Dim doctoprint As New System.Drawing.Printing.PrintDocument()
                doctoprint.PrinterSettings.PrinterName = "YourPrinterName" '(ex. "Epson SQ-1170 ESC/P 2")
                For i = 0 To doctoprint.PrinterSettings.PaperSizes.Count - 1
                    Dim rawKind As Integer
                    If doctoprint.PrinterSettings.PaperSizes(i).PaperName = "MyCustomFormatName" Then
                        rawKind = CInt(doctoprint.PrinterSettings.PaperSizes(i).GetType().GetField("kind", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes(i)))
                        oRpt.PrintOptions.PaperSize = rawKind
                        Exit For
                    End If
                Next

    the bold where it is giving an error that object reference not set to an instance of object
    please help me it is required for the survive
    Sunday, March 29, 2009 3:56 PM

Answers

  • You need to set your printer to a valid printer, unless you are printer named "YourPrinterName"

    Also I think you are possibly in the wrong forum :)
    MCP,MCAD,MCSD.NET,MCTS*7,MCPD*3,MCITP*2,MCDBA Blog: http://certsandprogs.blogspot.com
    • Marked as answer by Ken Rosen_MS Saturday, April 11, 2009 7:34 PM
    Sunday, March 29, 2009 4:49 PM

All replies

  • You need to set your printer to a valid printer, unless you are printer named "YourPrinterName"

    Also I think you are possibly in the wrong forum :)
    MCP,MCAD,MCSD.NET,MCTS*7,MCPD*3,MCITP*2,MCDBA Blog: http://certsandprogs.blogspot.com
    • Marked as answer by Ken Rosen_MS Saturday, April 11, 2009 7:34 PM
    Sunday, March 29, 2009 4:49 PM
  • And make sure to post questions like these in the correct forums. This is for Microsoft training and certifications.
    Michael D. Alligood,
    MCITP: Enterprise Support Technician, Consumer Support Technician
    MCTS: Windows Vista - Configuration,
    MCSA, MCDST, MCP, A+, Network+

    The I.T. Classroom Blog
    Start. Research. Plan. Perform. Finish. Test. Evaluate.
    Sunday, March 29, 2009 6:42 PM