Cannot click macro button while in page break preview?

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
Hello, I am trying to use a macro button that allows the user to set the page breaks. The goal would be to have the button work as listed below...

  1. If ActiveSheet is in PageBreakPreview mode, then switch back to normal mode
  2. If ActiveSheet is in Normal mode, then switch to PageBreakPreview

As a result, if the button hasn't been clicked yet, then the sheet will be in normal mode. Then, the person would click the button to set the page break. Then, they would click the button again to confirm page breaks and switch back to normal mode.

But... it also appears that when I switch it to page break preview to set my page breaks, I will not be able to click the macro button again? Is there a way around it?

Here is my code thus far. The bold/underlined/italicized line is where I need to adjust things.

Code:
Sub SetPageBreaks()
MsgBox "Once you are finished setting the page breaks, please re-click the ""Set Page Break Button"" to confirm. "
[U][B][I]ActiveWindow.View = xlPageBreakPreview[/I][/B][/U]
MsgBox "Page Breaks set up complete. Select the program you would like to export to."
End Sub
 

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
UPDATE: Sorry, I am able to click the macro button while in page break preview. I just forgot to assign the macro to the button, as I was just using the run command on the vba dashboard.
 

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
This code seemed to work. Thank you.

Code:
Sub SetPageBreaks()
If ActiveWindow.View <> xlPageBreakPreview Then
    MsgBox "Once you are finished setting the page breaks, please re-click the ""Set Page Break Button"" to confirm completion. "
    ActiveWindow.View = xlPageBreakPreview
Else
    ActiveWindow.View = xlNormalView
    MsgBox "Page Break set up complete." & Chr(10) & Chr(10) & "Now, select the program you would like to export to."
End If
End Sub
 

Forum statistics

Threads
1,082,258
Messages
5,364,088
Members
400,779
Latest member
lumers

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top