Link to home
Start Free TrialLog in
Avatar of JulienVan
JulienVanFlag for France

asked on

How to display page limits in Excel?

Hello,

Would you know how to code a macro to display the page limits in Excel, which appear dashed after a print preview?

Thanks by advance
ASKER CERTIFIED SOLUTION
Avatar of jppinto
jppinto
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or, after you make a Print Preview, you will see the dashed points that you've mentioned.
Avatar of JulienVan

ASKER

Thanks for your response, I thought that I could show print preview and cancel it, so the page limits would be displayed, but it's not possible, because second line of following function is processed only when print preview is closed by user.

Would you have any idea to do that with another maneer?
        public static void ShowPageLimits(Excel.Worksheet sheet)
        {
            sheet.PrintPreview(oMissing);
            sheet.Application.SendKeys("{ESC}", oMissing);
        }

Open in new window

SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks guys, I've got it with page break preview!
        public static void ShowPageLimits(Excel.Application app)
        {
            app.Application.ScreenUpdating = false;
            app.Application.ActiveWindow.View = Microsoft.Office.Interop.Excel.XlWindowView.xlPageBreakPreview;
            app.Application.ActiveWindow.View = Microsoft.Office.Interop.Excel.XlWindowView.xlNormalView;
            app.Application.ScreenUpdating = true;
        }

Open in new window

Some VB or C# code would have been helpful.