How to: Hide controls on worksheets when printing

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

When you print a Microsoft Office Excel document that contains Windows Forms controls, the controls are visible on the printed worksheet. You can hide the controls when printing a worksheet.

Applies to: The information in this topic applies to document-level projects for Excel. For more information, see Features available by Office application and project type.

Note

If you hide controls that display data, such as a TextBox, the data in the control will not be visible on the printed worksheet.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Personalize the Visual Studio IDE.

To hide controls when a worksheet is printed

  1. Create or open an Excel project in Visual Studio and verify that Sheet1 is visible in the designer. For information about creating projects, see How to: Create Office projects in Visual Studio.

  2. From the Common Controls tab of the Toolbox, drag a Button control to a cell on Sheet1.

  3. In the Properties window, set the PrintObject property to False.

See also