mari_hitz
07-22-2012, 04:32 PM
Hi Everybody,
I am new here and in the world of VBA code for word.
I am trying to create a document for people to send me templates of e-mails and where the variable's strings are supposed to be written I would like to insert a code in a button for the text to be inserted where the cursor is.
The code that I have used I founded in the net, it works fine, however when I save and close the document, the text inserts at the end of the document instead of where the cursor is, do you have any idea why?
This is the code:
Sub InsertAfterMethod() Dim MyText As String Dim MyRange As Object Set MyRange = ActiveDocument.Range MyText = "<Replace this with your text>" MyRange.InsertAfter (MyText) End Sub
I am new here and in the world of VBA code for word.
I am trying to create a document for people to send me templates of e-mails and where the variable's strings are supposed to be written I would like to insert a code in a button for the text to be inserted where the cursor is.
The code that I have used I founded in the net, it works fine, however when I save and close the document, the text inserts at the end of the document instead of where the cursor is, do you have any idea why?
This is the code:
Sub InsertAfterMethod() Dim MyText As String Dim MyRange As Object Set MyRange = ActiveDocument.Range MyText = "<Replace this with your text>" MyRange.InsertAfter (MyText) End Sub