malcmail
11-13-2017, 06:17 AM
Been using VBA for longer than I care to remember but always in Excel. Branching out into Word and got a bit of a headache.
I have a document with a series of ContentControls (rich text). The VBA needs to populate the content of these based on user input. I have one version so that a userform simply cycles through 5 questions and pops these in. Due to a change in structure it is now a number of forms. Getting the info in is no problem but actually getting it into the text itself is the problem.
WHat I ideally need to do is rather than reference the CC by name is to do them by number in the document. But I cannot work out how to do it. So far I've got...
ActiveDocument.ContentControls.Item(answer_loop).Range.Text = fmSingle.Controls("txt_" & answer).Value
....within a loop (which counts from, say, 5 to 8) to try and allocate the input to the correct CC. What am I doing wrong / have I missed?
TIA
Turns out it was a counting issue rather than the code ie idiot error!
I have a document with a series of ContentControls (rich text). The VBA needs to populate the content of these based on user input. I have one version so that a userform simply cycles through 5 questions and pops these in. Due to a change in structure it is now a number of forms. Getting the info in is no problem but actually getting it into the text itself is the problem.
WHat I ideally need to do is rather than reference the CC by name is to do them by number in the document. But I cannot work out how to do it. So far I've got...
ActiveDocument.ContentControls.Item(answer_loop).Range.Text = fmSingle.Controls("txt_" & answer).Value
....within a loop (which counts from, say, 5 to 8) to try and allocate the input to the correct CC. What am I doing wrong / have I missed?
TIA
Turns out it was a counting issue rather than the code ie idiot error!