Filling Content controls...

newguy

Well-known member
Joined
Jun 30, 2008
Messages
611
Location
Denver Co, USA
Programming Experience
1-3
I am trying to fill diff content controls with text from my form, here is my code, and the first content control fills but the second one does not, any ideas?

VB.NET:
 Dim objcc As Microsoft.Office.Interop.Word.ContentControl
 For Each objcc In oDoc.ContentControls
                If objcc.Title = "Units" Then
                    objcc.Range.Text = "Units Assigned to incident : " & TextBox2.Text
                End If
                If objcc.Title = "Narrative" Then
                    objcc.Range.Text = TextBox1.Text
                End If
                Exit For
            Next

Have also tried this... to no avail.

VB.NET:
  For Each objcc In oDoc.ContentControls
                If objcc.Tag = "Units" Then
                    objcc.Range.Text = "Units Assigned to incident : " & TextBox2.Text
                End If
                Exit For
            Next
            Dim objcc2 As Microsoft.Office.Interop.Word.ContentControl
            For Each objcc2 In oDoc.ContentControls
                If objcc2.Tag = "Narrative" Then
                    objcc2.Range.Text = TextBox1.Text
                End If
                Exit For
            Next
 
Last edited:
Back
Top