Link to home
Start Free TrialLog in
Avatar of hesaigo999ca
hesaigo999ca

asked on

vb printer object probs with changing landscape - portrait in middle of job

I am using a printer object from vb to handle my print jobs, I have set the usual parameters to use it, does any one know how to circumvent the problems associated with changing the landscape or portrait & back in the middle of a print job (obviously before its gone to the printer, but as it is accumulating into a full job)

my problem is that once i have set the print job parameter for landscape or portrait, it seems i need to change it back again
on my next job only, I cant do it in the middle of a printout, such as having in the same job, some lanscape and some portrait,
usually without starting a totally new job.

Any ideas?

links would be very welcome for this problem.

Is this a known issue , and if so, where is the documentation for this problem on microsoft websites, i cant seem to find any

thanks  ; )

Avatar of nffvrxqgrcfqvvc
nffvrxqgrcfqvvc

Option Explicit

Public Enum Orientationz
vbPRORPortrait = 1
vbPRORLandscape = 2
End Enum

Public Sub SetOrientationType(oPrint As Orientationz)
Select Case oPrint
        Case vbPRORPortrait
            Printer.Orientation = vbPRORPortrait
                Debug.Print "Print all my portrait images here"
        Case vbPRORLandscape
            Printer.Orientation = vbPRORLandscape
                Debug.Print "Print all my landscape images here"
End Select
End Sub

Private Sub Form_Load()

SetOrientationType vbPRORPortrait
SetOrientationType vbPRORLandscape

End Sub
Avatar of hesaigo999ca

ASKER

I guess you didnt understand what I was trying to say.

I have tried the above normal way of assigning the orientation, but I guess you can not change it in the middle of creating a print job.

Have you tested your above statement with multiple pages, and have 3 diff. types of pages within the same print job?
1 landscape, one portrair then one landscape, does it come out as it should or have you received any errors concerning the changes or maybe bad output?

you can not do this in the middle of a document.

you can however send a printer.enddoc, change the orientation, then continue on with the job so that you are essentially sending multiple documents to the printer for the same "job."
this is not acceptable, and I would not be able to use this, as I have stated, using the vb printer object has its problems.

I am unsure if there is really anything else that could be done, other then just implement an order scheme to set all documents together that have their diff.

I am looking for hardcore implementations of bypassing this problem though, such as using third-party softwares or even a diff. object that can be manipulated in very much the same way as the vb printer object .
A little more info please.  What specifically makes the enddoc unacceptable?  If I know that, I might be able to help further.
If you want to interupt the print I belive you use KillDoc
enddoc simply tells the printer that a document is finished and allows you to reset the settings like orientation.  it would also queue up in the printer as a separate document.  other than that, as far as i know, it's meaningless
ASKER CERTIFIED SOLUTION
Avatar of nffvrxqgrcfqvvc
nffvrxqgrcfqvvc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i created a begindoc function & closedoc function, but
nedd a changedoc function to be called before a closedoc function so that i can change it in the middle of the job, so lets say before you close the document, you would have 3 lanscape 2 portrait then 2 more landscape then closedoc.

specifics of the code could be viewed like this

begindoc(default portrait)
print....
changedoc(landscape)
print...
changedoc(portrait)
print...
changedoc(landscape)
print...
closedoc
Have you looked at the link I posted above?
Here is a stripped down example based on MSDN without the listbox's and such..hope this works!

Option Explicit
Private Declare Function Escape Lib "gdi32" (ByVal hdc As Long, ByVal nEscape As Long, ByVal nCount As Long, ByVal lpInData As String, lpOutData As Any) As Long
Const PASSTHROUGH = 19
Const Portrait = "&l0O"

Private Sub Form_Load()
Dim Result As Long

Printer.Orientation = vbPRORLandscape
Printer.Print "Starting with vbPRORLandscape"

'Send escape to change orientation to PORTRAIT!
Result = Escape(Printer.hdc, PASSTHROUGH, 0, Chr$(27) + Portrait, 0&)

Select Case Result
      ' Enter each Case statement on one, single line.
      Case Is < 0: MsgBox "The PASSTHROUGH Escape is not supported by this printer driver.", 48
      Case 0: MsgBox "An error occurred sending the escape sequence.", 48
      Case Is > 0: MsgBox "Escape Successfully sent. Sending test printout to printer."
     
      Printer.Print "Did this print is PORTRAIT?"
      Printer.EndDoc
   End Select

End Sub
How did that work?
I had read your post, but did not reply this week-end as it was my b-day and I was pretty busy, but thanks, that is exactly what i needed. I will be able to make my own printer object with this methodology.

Cheers!  ; )