Results 1 to 3 of 3

Thread: INTERCEPT the and of printout job

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    INTERCEPT the and of printout job

    INTERCEPT the and of printout job and intercept if the printer have error during the job?

    possible?

    Code:
    Private Sub PRINT_REPORT()
    
        Dim XLWB As Object, WS As Object, XLAPP As Object
        Set XLAPP = CreateObject("Excel.Application")
        Set XLWB = XLAPP.Workbooks.Open(FileName:=STRWB, Editable:=True)
        Set WS = XLWB.Worksheets("REPORT")
        WS.Range("B2:AZ51").ClearContents
    
        CONTA = 0
    
        With WS
            .Application.ScreenUpdating = False
            For K = 0 To UBound(strDBRows_ESTRAI, 2)
                .Cells(strDBRows_ESTRAI(3, K) + 1, strDBRows_ESTRAI(4, K) + 1) = "X"
                .Cells(strDBRows_ESTRAI(3, K) + 1, 52) = .Cells(strDBRows_ESTRAI(3, K) + 1, 52) + 1
                CONTA = CONTA + 1
                DoEvents
            Next K
            .Application.ScreenUpdating = True
            'IMPOSTAZIONI PAGINA DI STAMPA
            .PageSetup.CenterHeader = "REPORT OMBRELLONI DEL: " & Format(GIORNO, "DD/MM/YYYY") & " - (ZONA: " & DXSX & ")"
            .PageSetup.LeftFooter = "REPORT STAMPATO IL:  " & Format(Date, "DD/MM/YYYY")
            .PageSetup.RightFooter = "NR:  " & CONTA
            .PageSetup.PaperSize = vbPRPSA4
            'IMPOSTAZIONI PAGINA DI STAMPA
        End With
    
    
        XLAPP.Activesheet.PrintOut Copies:=1, Collate:=True
    
        Set WS = Nothing
        XLWB.Close SaveChanges:=False
        Set XLWB = Nothing
        XLAPP.Quit
        Set XLAPP = Nothing
    
    End Sub

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: INTERCEPT the and of printout job

    XLAPP.Activesheet.PrintOut
    why would you use the activesheet object when you already have a worksheet object of the sheet you want to print
    Code:
    WS.PrintOut Copies:=1, Collate:=True
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,440

    Re: INTERCEPT the and of printout job

    Quote Originally Posted by luca90 View Post
    INTERCEPT the and of printout job and intercept if the printer have error during the job?

    possible?
    Don't think so. IIRC, the Printing routines in Office-VBA are "shoot and forget"
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

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