If you want to add " - i value: #- " where # is the value of i to the end of the paragraph, then use
Dim i As Long Dim para As Range For i = 1 To 3 Set para = ActiveDocument.Paragraphs(i).Range para.End = para.End - 1 para.InsertAfter " -i value: " & i & "- " Next i
-- Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis.
Doug Robbins - Word MVP
"Lilivati" <Lilivati[ at ]gmail.com> wrote in message news:1151607538.122641.302130[ at ]x69g2000cwx.googlegroups.com...
[Quoted Text] >I am playing around with VBA in Word to become familiar with it before > beginning a project. So far it has been going well, but I am currently > stumped on this InsertAfter issue. Basically to my mind it should > insert text after the selection, but on the same line. What it is > doing is inserting the text on a new line, which Word then considers to > be a new paragraph. Here is my little practice code: > > Sub Test() > Options.ReplaceSelection = False > > Dim i As Integer > > For i = 1 To 3 > Paragraphs(i).Range.Select > Selection.Copy > Application.Selection.InsertAfter " -i value: " & i & "- " > Selection.Paste > Next i > > ' (this is in here because leaving it false does some annoying things > to how backspace works) > Options.ReplaceSelection = True > End Sub > > I am sure there is something simple here I am missing, but for the life > of me I can't figure out what. >
|