Hawkvalley1
asked on
How to fill several content controls in a Word2007 template?
Hi All.
Trying to fill 2 diff. content controls on my template, with the following code I get the first one to fill but not the second one, any ideas?
Trying to fill 2 diff. content controls on my template, with the following code I get the first one to fill but not the second one, any ideas?
Dim objcc As Microsoft.Office.Interop.Word.ContentControl
For Each objcc In oDoc.ContentControls
If objcc.Type = WdContentControlType.wdContentControlText Then
If objcc.Tag = "Units" Then
objcc.SetPlaceholderText(Nothing, Nothing, TextBox2.Text)
oDoc.Content.Paragraphs.Add()
End If
If objcc.Tag = "Narrative" Then
objcc.SetPlaceholderText(Nothing, Nothing, TextBox1.Text)
End If
End If
Exit For
Next
'or
Dim objcc As Microsoft.Office.Interop.Word.ContentControl
For Each objcc In oDoc.ContentControls
If objcc.Type = WdContentControlType.wdContentControlText Then
If objcc.Tag = "Units" Then
objcc.Range.Text = TextBox2.Text
oDoc.Content.Paragraphs.Add()
End If
If objcc.Tag = "Narrative" Then
objcc.Range.Text = TextBox1.Text
End If
End If
Exit For
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again...
ASKER