This approach is useful when you need a more complex replacement, like replacing your placeholders with hyperlinks, tables, pictures, or some other content. You can also search for all occurrences of a specified String or Regex using one of the ContentRange.Find methods and process the resulting ContentRange objects as needed. You can easily find all the parts of a Word document that contain the specified text or match the specified regular expression and replace them with desired text by using one of the ContentRange.Replace methods.
For instance, you can use Mail Merge, Update Form, Content Controls Mapping, Modify Bookmarks, or the following find and replace approach.
If the lorem() generator is not working on your copy of Word, you probably have turned off the Replace text as you type option available under. Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide offers several ways in which you can manipulate a Word document's content to import new or replace existing data using C# or VB.NET code. The lorem() function is available in Word 2007 but if you are using a previous version of Office, you may use the good old rand() function to insert any amount of random text in your Word Document. ObjCC.SetPlaceholderText, , "Select your favorite animal "ĬontentControl Object Support and feedback Set objCC = (wdContentControlDropdownList)
The following example inserts a new drop-down list content control into the active document, sets the title and placeholder text, and then inserts several new items into the list. If all parameters are omitted, the placeholder text is blank. Keep in mind that placeholder text can go anywhere you would normally type text (text boxes, columns, sidebars, tables, etc.).
To add lorem ipsum text in Word: Place the cursor where you would like the text. Shows how to find and replace placeholder text in Word document with another text, link, table, or image by using GemBox.Document library from C and VB.NET application. If more than one parameter is used, Microsoft Word uses the text specified in the first parameter. Placeholder text can be dropped into the spot until you receive the real text for your project.
Only one of the parameters is used when specifying placeholder text. Specifies the contents of the placeholder text. Specifies a Range object that contains the contents of the placeholder text. Specifies a BuildingBlock object that contains the contents of the placeholder text. Note that Firefox adds a lower opacity to the placeholder, so we use opacity: 1 to fix this. SetPlaceholderText( _BuildingBlock_, _Range_, _Text_ )Įxpression An expression that returns a ContentControl object. Click on Placeholder> Developer tab> Properties in Control section> Enable the box of Remove content control when contents are edited> OK. For example, a programmer may know that she needs a certain number of values or variables, but doesnt yet know what to input. In computer programming, a placeholder is a character, word, or string of characters that temporarily takes the place of the final data. Sets the placeholder text that displays in the content control until a user enters their own text. Solution: In the Properties of Placeholder, we need to enable the option Remove content control when contents are edited. Placeholder text may refer to any of the following: 1.