Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble inserting text to document through code

Status
Not open for further replies.

CTOROCK

Programmer
May 14, 2002
289
US
I am programming in Word and have a combo box that has numbers 1-100. When selected depending on the number a phrase is inserted in the Word document. i have an array , Para(1000). The reason I have 1000 is because Some phrases have more that one paragraphs so if para(62) has 3 paragraphs, I use the other three as Para(621),622,623 etc.
I do this becuse I don't want the user to see a 61 then a jump to 65 in the list box because the other three are part of 62. So I have this in my code:

If ComboBox1.Text = 62 Then
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
Selection.TypeParagraph
Selection.InsertAfter para(621)
Selection.TypeParagraph
Selection.TypeParagraph
Selection.InsertAfter para(622)
Selection.TypeParagraph
Selection.TypeParagraph
Selection.InsertAfter para(623)
Selection.TypeParagraph
Selection.InsertAfter para(624)
Selection.TypeParagraph
Selection.InsertAfter para(625)
Selection.TypeParagraph
Selection.InsertAfter para(626)
Selection.TypeParagraph
Selection.InsertAfter para(627)
Exit Sub
End If

But this doesn't work. I only get para(627)
Or is there a way I can say

ParaNo = combobox1.text

if (paraNo & 1) ?exists? then
Selection.InsertAfter para(ParaNo & 1)
and go on until there aren't anymore?

Please help
Thanks in advance
ERic
"The greatest risk, is not taking one."
 
I figured it out, i just used typetext insted of insertafter
"The greatest risk, is not taking one."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top