Hide Page Breaks in Excel 2010

Closed
Report
Posts
6
Registration date
Friday October 16, 2015
Status
Member
Last seen
August 8, 2017
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Hello,
Is it possible to hide page breaks in excel while shifting from print preview to normal view using vba?
I know to remove pages breaks manually (options->advanced->show page breaks). I want to remove it through vba.

Thanks in advance!


4 replies

Posts
2847
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
January 13, 2022
491
Poojapriya,

A good way to figure out the commands used by vba is to use the macro recorder.

Start recording, change the option, stop recording, take a look at the code.

Let us know if you get stuck somewhere.

Best regards,
Trowa
0
Thanks Trowa!. I tries your answer it shows the command "Activesheet.displaypagebreaks=false". But i need to disable page break option only for a particular workbook. If i done it manually, it will affect other workbooks also. Any ideas?


Pooja.
0
Posts
2847
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
January 13, 2022
491
Hi Pooja,

The command only applies to a single sheet. You could write a loop to go through each sheet of your workbook.

I've done it manually as well and that also only applies to the current.

*

After some testing I noticed that by default the page breaks are turned off. If I turn them on, save, close and reload workbook, the page breaks are turned off again.

So I guess you need to use the command ending with True for the sheets you want to show the page breaks (placing the "loop through sheets code" under ThisWorkbook, using "Private Sub Workbook_Activate()" as the first line) by default.

Let me know if I can help you further.

Best regards,
Trowa
0
Thanks Trowa!. I will try out your opinion and let you know .
0
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
One of the best way to find out that would be, start the macro recorder, manually do what you want to do, stop the recorder. recorder should create the macro for you.
0