title: Exception for add document variable(I cant figure out)
body: <p>I cant figure out where is my error is.Below is my code and the exception:      </p>
  
  <pre><code>    Imports DocumentFormat.OpenXml
      Imports DocumentFormat.OpenXml.Packaging
      Imports DocumentFormat.OpenXml.Wordprocessing
  
  Public Class Form1
  
  Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      'Create a word file
      Using wordDocument As WordprocessingDocument = WordprocessingDocument.Create("C:\Users\local\Desktop\vb testing purpose\test.docx", WordprocessingDocumentType.Document)
          ' Add a main document part. 
          Dim mainPart As MainDocumentPart = wordDocument.AddMainDocumentPart()
          ' Create the document structure and add some text.
          mainPart.Document = New Document()
  
          Dim body As Body = mainPart.Document.AppendChild(New Body())
          Dim para As Paragraph = body.AppendChild(New Paragraph())
          Dim run As Run = para.AppendChild(New Run())
          run.AppendChild(New Text(""))
      End Using
      Dim strDoc As String = "C:\Users\local\Desktop\vb testing purpose\test.docx"
      Dim varname As String = "Hi"
      Dim varvalue As String = "Bryan"
      AddDocVar(strDoc, varname, varvalue)
     End Sub
  
     Public Sub AddDocVar(ByVal sender As Object, ByVal varName As String, ByVal varValue As String)
     Dim mainPart As MainDocumentPart = sender.MainDocumentPart
      Dim settingsPart As DocumentSettingsPart = mainPart.DocumentSettingsPart
      settingsPart.Settings = New Settings(New DocumentVariables(New DocumentVariable() With {.Name = varName, .Val = varValue}))
  
  End Sub
   End Class
  </code></pre>
  
  <p>Comes out a </p>
  
  <blockquote>
    <p>exception(System.MissingMemberException: 'Public member 'MainDocumentPart' on type 'String' not found.') in</p>
  
  <pre><code>Dim mainPart As MainDocumentPart = sender.MainDocumentPart
  </code></pre>
  </blockquote>