Results 1 to 4 of 4

Thread: Page orientation problem with VB & Crystal Reports

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    6

    Page orientation problem with VB & Crystal Reports

    I am writing a VB app that provides the user with a menu of reports written in Crystal Reports 4.6. When the user selects a report, it is shown in the Crystal Reports preview window from where it can be printed to the selected printer.

    My problem is that the page orientation is derived from the printer, not the report. I need the orientation to be portrait or landscape depending on the report selected, not the printer. If the selected printer is set up as portrait but the report is landscape, I need it to print in landscape (and vice versa). I don't want the user to have to touch the printer setup.

    I have found the following code segment that looks like it might be a solution:

    Dim repApp As CRAXDRT.Application
    Dim cryReport As CRAXDRT.Report
    Set cryReport = repApp.OpenReport(strRptName, 1) 'where strRptName has been set up as the report name
    cryReport.PaperOrientation = crLandscape

    However, it gives me a "User-defined type not defined" error on compile. I need to know how to make it work so that I can test it. Or if you don't think it's the solution I need, perhaps you have some other suggestions?

    Thanks!

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Page orientation problem with VB & Crystal Reports

    Please post the code where you call and print the rpts
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    6

    Re: Page orientation problem with VB & Crystal Reports

    This is the VB code I'm using:

    Public Sub PreviewReport(ByVal ReportName As String)
    'This sub-procedure displays a given Crystal report in a preview window from where it can be printed if desired
    Dim ErrorCode As Integer
    cryReport.ReportFileName = App.Path & "\" & ReportName 'Report located in application folder
    cryReport.WindowTitle = App.Title & ": " & ReportName 'App name concatenated to report name
    cryReport.WindowState = 2 'Maximized
    Set Printer = Printers(cmbPrinter.ListIndex) 'Selected from a combo that has been populated with all printers
    cryReport.PrinterName = Printer.DeviceName
    cryReport.PrinterPort = Printer.Port
    cryReport.PrinterDriver = Printer.DriverName
    ErrorCode = cryReport.PrintReport
    If ErrorCode > 0 Then
    LogError 'This sub-procedure reports the error to the user and adds it to the error log
    End If
    End Sub

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    6

    Re: Page orientation problem with VB & Crystal Reports

    Sorry, I meant to add that the Destination property of the crystal report control (cryReport) is set to preview, not print.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width