Training
Module
Build Office Add-ins for Word - Training
This module walks through development of Office Add-ins for Microsoft Word.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You can hide text in a document by setting the Hidden property of the Font for a particular range of text.
For example, you can temporarily hide the text within a Bookmark (in a document-level customization) or a Bookmark (in a VSTO Add-in) before sending a document to a printer.
Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Word. For more information, see Features available by Office application and project type.
Create a procedure that hides all text that is in a specified range.
Create a procedure that unhides all text that is in a specified range.
Pass the range of a bookmark to the HideText
method, print the document, and then pass the same range to the UnhideText
method.
The following code example can be used in a document-level customization. To use this example, run it from the ThisDocument
class in your project.
HideText(bookmark1.Range);
object oTrue = true;
object oFalse = false;
object range = Word.WdPrintOutRange.wdPrintAllDocument;
object items = Word.WdPrintOutItem.wdPrintDocumentContent;
object copies = "1";
object pages = "";
object pageType = Word.WdPrintOutPages.wdPrintAllPages;
this.PrintOut(
ref oTrue, ref oFalse, ref range, ref missing, ref missing, ref missing,
ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue,
ref missing, ref oFalse, ref missing, ref missing, ref missing, ref missing);
UnhideText(bookmark1.Range);
The following code example can be used in a VSTO Add-in. This example uses the active document. To use the example, run it from the ThisAddIn
class in your project.
HideText(bookmark1.Range);
this.Application.ActiveDocument.PrintOut(true, false, Word.WdPrintOutRange.wdPrintAllDocument,
Item:Word.WdPrintOutItem.wdPrintDocumentContent, Copies:"1", Pages:"",
PageType:Word.WdPrintOutPages.wdPrintAllPages, PrintToFile:false, Collate:true,
ManualDuplexPrint:false);
UnhideText(bookmark1.Range);
This code example assumes that the document contains a Bookmark control (in a document-level customization) or Bookmark control (in a VSTO Add-in) that is named bookmark1
.
Training
Module
Build Office Add-ins for Word - Training
This module walks through development of Office Add-ins for Microsoft Word.