Solved

Help Me, Printing Problem

Posted on 1999-01-06
2
192 Views
Last Modified: 2012-08-13
Can anyone tell me if there is a way to force a print to come out in Landscape instead of Portrait. I'm Using Crystal Report Activex Control in V.B 5.0 and can't print in Landscape Orintation when the defaul orintation is Portrait
0
Comment
Question by:diego_mendoza
2 Comments
 

Accepted Solution

by:
torsk earned 100 total points
ID: 1454175
I think you have to start the report whith code:

Public Sub OpenTheReport( ByRef CurrentFrm As Form)
On Error GoTo ErrorHandler
    Dim Result%, jobnum%, mainjob%, dialogflag%, resultlong&
    Dim JobInfo As PEJobInfo, TempText$
    Dim PrintData As Printer
    Dim crDEVMODE As DevMode
    Dim HasSavedData As Long
    Dim PrintOptions As PEPrintOptions
    Dim Msg As String
       
    Result% = PEOpenEngine()
    If Result% = 0 Then
        HourGlass False
        MsgBox "Cant get conntact with Crystal Report!",
        vbOKOnly + vbCritical, "Systemerror"
        Exit Sub
    End If

    JobInfo.StructSize = PE_SIZEOF_JOB_INFO
    jobnum% = PEOpenPrintJob("RepeortFilename")
       
    crDEVMODE.dmOrientation = 1 'or 2 this change the
                                 orientation
    crDEVMODE.dmDeviceName = "RptDeviceName"   'printername
    crDEVMODE.dmSpecVersion = &H320 'version of the DEVMODE
                               structure Win32
    crDEVMODE.dmSize = 68                              
    crDEVMODE.dmFields = &H1
    Result% = PESelectPrinter(jobnum%, "DriverName",
    "DeviceName", "Port", crDEVMODE)
   
    PrintOptions.StructSize = PE_SIZEOF_PRINT_OPTIONS
    Result% = PEGetPrintOptions(jobnum%, PrintOptions)
    PrintOptions.StartPageN = Rpt.RptFraSide
    PrintOptions.stopPageN = Rpt.RptTilSide
    PrintOptions.nReportCopies = Rpt.RptKopier
    Result% = PESetPrintOptions(jobnum%, PrintOptions)
   
    If Rpt.RptPreview Then  
        Result% = PEOutputToWindow(jobnum%, Rpt.RptTittel, 0, 0, Screen.Width, Screen.Height, WS_MAXIMIZE + WS_SYSMENU + WS_MAXIMIZEBOX + WS_THICKFRAME, 0)
        Result% = PEStartPrintJob(jobnum%, True)       uforutsette resultater
       
        If Result% = 0 Then
            Msg = "Error"
            ShowErrMsg (Msg)
            GoTo Avslutt
        End If
       
        Result% = 1
        Do While Result% <> 0
            DoEvents
            Result% = PEGetWindowHandle(jobnum%)
        Loop
    Else                    
        Result% = PEEnableProgressDialog(jobnum%, True)
        Result% = PESetDialogParentWindow(jobnum%, CurrentFrm.hwnd)
        Result% = PEOutputToPrinter(jobnum%, Rpt.RptKopier)
        Result% = PEStartPrintJob(jobnum%, True)            

        Result% = PEGetJobStatus(jobnum%, JobInfo)
        Select Case Result%
            Case PE_JOBNOTSTARTED
                TempText$ = "Cant start"
            Case PE_JOBINPROGRESS
                TempText$ = "Printing"
            Case PE_JOBCOMPLETED
                TempText$ = "Printing ready"
            Case PE_JOBFAILED
                TempText$ = "Error"
            Case PE_JOBCANCELLED
                TempText$ = "Cancel printing"
        End Select
       
        If Result% <> PE_JOBCOMPLETED Then MsgBox TempText, vbInformation + vbOKOnly
       
    End If
       
    GoTo Avslutt
   
ErrorHandler:
    HourGlass False
    ShowErrMsg
Avslutt:
    PEClosePrintJob jobnum%
    PECloseEngine
    HourGlass False
End Sub
0
 

Author Comment

by:diego_mendoza
ID: 1454176
Thanks you.


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using Access 8 58
Saving history changes to sub form 4 35
Macro Excel - Multiple If conditions 2 62
I need help embedding an image as HTML in my vb.net application 3 45
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now