title: Change value of Word MailMerge field using VBA
body: <p>I have a document with MailMerge fields, however I do not want to use the whole datasource->mailmerge idea. Instead I am presenting a UserForm on Autonew() and asking the user to type the data into the fields.</p>
  
  <p>The reason is because this document is to "merged" with one row of data so it is a waste of time asking the user to do the whole data source thing for one row.</p>
  
  <p>I have a working solution using DocVariables which I'm sure most people will say is the correct way to do it, however this client likes the idea of "seeing" the mailmerge variable (such as &lt;&lt;1>>) in the source document. They know they can use Alt-F9 to display codes to see the DocVariables, but they insist on wanting to use MergeFields.</p>
  
  <p>Using DocVariables I do it using the following. This works so I know I have the right idea and that the rest of my code works fine.</p>
  
  <pre><code>ActiveDocument.Variables("varSurame").Value = .txtSurname
  </code></pre>
  
  <p>However, I cannot workout how to do the same thing with merge fields. I want to do something like the below (but there is no "value" property to set).</p>
  
  <pre><code>ActiveDocument.MailMerge.Fields("Surname").value = .txtSurname
  </code></pre>
  
  <p>The .text property is readonly so I cannot use that.</p>
  
  <p>The following renders "Bookmark not defined" errors.</p>
  
  <pre><code>ActiveDocument.MailMerge.Fields("Surname").Code.Text = .txtSurname
  </code></pre>
  
  <p>Any ideas on how I can programmatically change the value of a mail merge field without using a datasource.</p>