Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6883245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:21:26+00:00 2026-05-27T05:21:26+00:00

I have a requirement to create read-only merge fields in Word. I’ve already tried

  • 0

I have a requirement to create read-only merge fields in Word.

I’ve already tried using the Locked property which can be seen below.The description of this property states – When a field is locked you cannot update field results which sounds like a perfect fit for my problem but this doesn’t seem to be working

Below is the code i use to add the merge field to MS Word:

using Word = Microsoft.Office.Interop.Word;  

Word.Range currentRange = Globals.ThisAddIn.Application.Selection.Range;
Word.MailMerge merge = Globals.ThisAddIn.Application.ActiveDocument.MailMerge;
merge.Fields.Add(currentRange, selectedNode.LocalName).Locked = true;

Once I run the code above and the field is created in Word, I am still able to right click it and select “Edit Field” where I can potentially rename the field or perform other changes without getting any errors or preventions from Word.

Edit Field is enabled

If anyone implemented something like this before, please share your knowledge.

Here is some insight on the technologies:

  • The solution is targeted at MS Word Office 2010
  • It must be written in .NET C# 3.5
  • Cannot use Open Xml SDK, the fix must be performed using Office Interop
  • The solution must achieve the desired goals without making the whole document read-only
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:21:27+00:00Added an answer on May 27, 2026 at 5:21 am

    Thank you for the replies, however I needed to only make the merge fields read-only the rest of the document should still stay as is.

    A colleague of mine found a nice way to achieve what I was looking for, just sharing it in case someone else may need this functionality:

    All you need to do is create a ContentControl object and add your merge field to the content control.
    Set the LockContents property to true. This property is used to determine whether a user is allowed to edit the contents of a content control.

    using Word = Microsoft.Office.Interop.Word;
    
    object missing = System.Type.Missing;
    
    Word.Selection PosRange = Globals.ThisAddIn.Application.Selection;
    Microsoft.Office.Interop.Word.ContentControl cntCtrl;
    cntCtrl = PosRange.Range.ContentControls.Add(Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlRichText, ref missing);
    
    object fldType = Microsoft.Office.Interop.Word.WdFieldType.wdFieldMergeField;
    object fldText = "Employee";
    Microsoft.Office.Interop.Word.Field fld = cntCtrl.Range.Fields.Add(cntCtrl.Range, ref fldType, ref fldText);
    cntCtrl.LockContents = true;
    

    In the image below a merge field is hosted inside a content control, note users are now unable to edit the field

    Update and Edit field are disabled

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement to create a background processor that works only when the
I have a requirement to create a windows form control which has to detect
I have a requirement to allow selecting the text displayed in read only screens.
I have a requirement to create a xaml page with Semantic Zoom where the
I have a requirement to create a simple windows forms application that allows an
I have a requirement to create two different maps in C++. The Key is
I have a requirement to create a multi level treeview in ASP.Net (with VB)
If I have a requirement to create a data structure that has the following
For a project we have a requirement to create an interfacedefinition that will return
I am new to MySQL coming from Oracle. I have a requirement to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.