+ Reply to Thread
Results 1 to 2 of 2

Trouble hiding page breaks after running macro

Hybrid View

  1. #1
    Registered User
    Join Date
    12-29-2010
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    20

    Trouble hiding page breaks after running macro

    Hi,

    I have a regular office printer and receipt printer set up to my computer and am using the following code to switch to the receipt printer only when I need it.

    Sub PrintSheet()
    
    Dim STDprinter As String
    STDprinter = Application.ActivePrinter
        
        Application.ActivePrinter = "Receipt Printer on Ne00:"
        ActiveSheet.PrintOut
        Application.ActivePrinter = "\\ssaaes\BINARY_P1 on Ne06:"
        
    End Sub
    The problem is that once I run this macro, page breaks appear on every sheet in my workbook.

    I've tried using the following code to remove the page breaks but the macro is too taxing on the program and often crashes mid-macro.

    Sub Removeprintinglines()
    
    Dim wbBook As Workbook
    Dim wsSheet As Worksheet
    
    Set wbBook = ThisWorkbook
    
    For Each wsSheet In wbBook.Worksheets
    If Not wsSheet.Name = "Blank" Then
    wsSheet.Activate
    With ActiveWindow
        ActiveSheet.DisplayPageBreaks = False
    End With
    End If
    Next wsSheet
    ActiveSheet.ResetAllPageBreaks
    
    End Sub
    Does anyone have a more efficient workaround to removing the page breaks from all sheets or ensuring they never appear in the first place?

    Thanks

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Trouble hiding page breaks after running macro

    Hello Einstahb, let me know if the following works
    Sub Removeprintinglines()
    
        Dim wbBook As Workbook
        Dim wsSheet As Worksheet
    
        Set wbBook = ThisWorkbook
        For Each wsSheet In wbBook.Worksheets
            If Not wsSheet.Name = "Blank" Then
                wsSheet.DisplayPageBreaks = False
            End If
        Next wsSheet
    
    End Sub
    You'll find that removing selections and activations be less taxing on the program.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1