0
votes

I have around 60 pages of code that I have picked up and edited from another member of staff. What I have is a Userform where a person will enter some details to create a letter. This part is all good and working. The next part is where I am having troubles. Basically, if someone clicks a button then it will insert some autotext and fill in any bookmarks as necessary.

If chk1 = True Then
   ActiveDocument.AttachedTemplate.AutoTextEntries("1").Insert Where:=Selection.Range, RichText:=True
   ActiveDocument.Bookmarks("bm1").Select
   Selection.Text = txt1.Value
End If

If chk2 = True Then
   ActiveDocument.AttachedTemplate.AutoTextEntries("2").Insert Where:=Selection.Range, RichText:=True

End If Now what I am trying to figure out is how to change the selection/range to just below the insert. So when the autotext entry is input and after it has changed the bookmarks as required I would like the selection to be under it to start a new paragraph.

Example: Text text text text text text text

<- Selection will be here for entry of new autotext.

I have been looking online and I just don't know how to do it! I Should mention that this is sort of in the middle of the document. I have a signature and stuff below it so it doesn't really work with the make the selection the last paragraph sor of thing.

1

1 Answers

0
votes

If you want to know something like this, ask Word.

Put cursor where macro leaves it, Alt + T, M, R. Move by keyboard the cursor where you want it. Turn off recording (Alt + T, M, R). Copy and paste from the new macro into your macro.


These are some examples from doing the same thing in Excel.

You are using Excel and you can record it in Excel and have Excel write your code.

Alt + T, M, R

then Home key then Up Arrow. Stop recording.

Look what Excel wrote

Selection.End(xlUp).Select

or if you had of recorded Go To dialog

Application.Goto Reference:="R1C1"

or if you had of recorded Ctrl + Home

Range("A1").Select