title: transfer data from word to excel via vba
body: <p>I have a form in ms word with some of the fields are content control and some (which are the radio buttons) are ActiveX control. I want to automatically transfer hundred word forms to an excel file. I use the following vba code:</p>
  
  <pre><code>Sub getWordFormData()
  Dim wdApp As New Word.Application
  Dim myDoc As Word.Document
  Dim CCtl As Word.ContentControl
  Dim myFolder As String, strFile As String
  Dim myWkSht As Worksheet, i As Long, j As Long
  
  myFolder = "C:\Users\alarfajal\Desktop\myform"
  Application.ScreenUpdating = False
  
  If myFolder = "" Then Exit Sub
  Set myWkSht = ActiveSheet
  ActiveSheet.Cells.Clear
  Range("A1") = "name"
  Range("a1").Font.Bold = True
  Range("B1") = "age"
  Range("B1").Font.Bold = True
  Range("C1") = "gender"
  Range("C1").Font.Bold = True
  Range("D1") = "checkbox1"
  Range("D1").Font.Bold = True
  Range("E1") = "checkbox2"
  Range("E1").Font.Bold = True
  Range("F1") = "singlechoice1"
  Range("F1").Font.Bold = True
  Range("G1") = "singlechoice2"
  Range("G1").Font.Bold = True
  
  
  
  i = myWkSht.Cells(myWkSht.Rows.Count, 1).End(xlUp).Row
  strFile = Dir(myFolder &amp; "\*.docx", vbNormal)
  
  While strFile &lt;&gt; ""
      i = i + 1
  
      Set myDoc = wdApp.Documents.Open(Filename:=myFolder &amp; "\" &amp; strFile, AddToRecentFiles:=False, Visible:=False)
  
      With myDoc
          j = 0
          For Each CCtl In .ContentControls
              j = j + 1
              myWkSht.Cells(i, j) = CCtl.Range.Text
          Next
          myWkSht.Columns.AutoFit
      End With
      myDoc.Close SaveChanges:=False
      strFile = Dir()
  Wend
  wdApp.Quit
  Set myDoc = Nothing: Set wdApp = Nothing: Set myWkSht = Nothing
  Application.ScreenUpdating = True
  
  End Sub
  </code></pre>
  
  <p>all the data (text fields, checkbox) are transferred successfully but, the radio button (which is ActiveX) is not transferred. </p>
  
  <p><strong>This is the word doc:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/UU1mz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UU1mz.png" alt="enter image description here"></a></p>
  
  <p><strong>This is the excel result:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/xFGxM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xFGxM.png" alt="enter image description here"></a></p>
  
  <p>How can I solve this problem? </p>