Consulting

Results 1 to 2 of 2

Thread: Excel 2013 Print Preview Code

  1. #1
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location

    Excel 2013 Print Preview Code

    Good morning, below is code that one of the guru's helped me with a while back. The code works great in excel 2010 but it does not seem to work properly in excel 2013. The idea is for the code to take the following sheets "IAP Cover", "202", "203", "205", "206", "208" and put them into print preview where the user can print or cancel printing. The code also counts the "204" sheets because there may be more than one of them.

    The problem in excel 2013 is that on the print preview screen, only the first sheet is visible "IAP Cover". When you press next page the "IAP Cover" remains visible. However the correct number of pages show and the correct sheets printout when print is selected.

    Anyone have an idea how to update the code for print preview to work correctly in excel 2013?

    Thanks
    Gary

    Sub PrintBasicIAP()
    'Opens up the sheets in print preview. You may cancel or print from the print preview screen.
    
    Dim ppWorksheets()
    Dim count As Long
    Dim ws As Worksheet
    Dim dummy As String
    
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    UserForm1.Hide
       
        ppWorksheets = Array("IAP Cover", "202", "203", "205", "206", "208")
        count = UBound(ppWorksheets)
        For Each ws In ThisWorkbook.Worksheets
            If StrComp(Left(ws.Name, 3), "204", vbTextCompare) = 0 Then
                count = count + 1
                ReDim Preserve ppWorksheets(count)
                ppWorksheets(UBound(ppWorksheets)) = ws.Name
            End If
        Next ws
    
       Sheets(ppWorksheets).PrintPreview
       Sheets("Print IAP").Select
    
    Call ShowUserform1(dummy)
    
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    End Sub

  2. #2
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    Interesting, if I click "next page" the first sheet is still visible. If I then click zoom, the correct page will now be visible. This works for all the pages, after clicking "next page" or "previous page" and the zoom, the appropriate page will be visible. Is this a flaw in excel 2013?

Posting Permissions

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