Results 1 to 4 of 4

VBA Trying to add page break...not working

Threaded View

  1. #1
    Registered User
    Join Date
    09-18-2006
    Posts
    30

    VBA Trying to add page break...not working

    I've written the following code to add a second page to the file when additional rows are needed. After the add, I'm trying to set the page break so that it breaks in the proper location. I've tried several different pieces of code, none seem to work.

    The following isn't giving me any error msg, yet the stubborn page break remains before row 65, rather than before row 62 where I want it.

    Any help on why this isn't working would be appreciated.

    
    Sub AddPage()
    '
        Application.ScreenUpdating = False
        ActiveSheet.Unprotect
        Application.Goto Reference:="BlankPage"
        Application.CutCopyMode = False
        Selection.Copy
    
        Range("A62").Select
        ActiveSheet.Paste
        ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$118"
        With ActiveSheet.PageSetup
            .PrintTitleRows = "$11:$14"
        End With
        ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$118"
        With ActiveSheet.PageSetup
            .FitToPagesWide = 1
            .FitToPagesTall = 2
        End With
        ActiveWindow.View = xlPageBreakPreview
            ActiveSheet.HPageBreaks.Add Before:=Rows(62)
        ActiveWindow.View = xlNormalView
        
        ActiveSheet.Shapes.Range(Array("Button 17")).Select
            Selection.OnAction = "RemovePage"
            Selection.Characters.Text = "Remove Page 2"
        
        Range("A14:A15").Select
        ActiveSheet.Protect
        Application.ScreenUpdating = True
      
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Page Layout (Page Break Preview) is not working with hidden rows in excel.
    By ebin charles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-31-2013, 03:32 AM
  2. Macro for page break in columns not working
    By dlorenzo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-01-2012, 01:06 PM
  3. Page break with Charts not working properly
    By bewa3u1 in forum Excel General
    Replies: 0
    Last Post: 02-27-2012, 03:55 PM
  4. Replies: 4
    Last Post: 01-31-2012, 05:48 AM
  5. [SOLVED] Right Click Menu not working when sheet is in Page Break Preview m
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-27-2006, 09:40 PM

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