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
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top