Hello,
I am creating a userform that takes a string and adds it to the end
of a different word file. For example, the current file has a text
string inputted from the user via the form, and I need to take that
string, then transfer it over to a existing file that already has text
in it and paste it at the end. Any help would be appreciated.

Rob

Re: Insert a selection at the end of a Word Document by Jean-Guy

Jean-Guy
Mon Jul 10 14:15:26 CDT 2006

RoVo was telling us:
RoVo nous racontait que :

> Hello,
> I am creating a userform that takes a string and adds it to the end
> of a different word file. For example, the current file has a text
> string inputted from the user via the form, and I need to take that
> string, then transfer it over to a existing file that already has text
> in it and paste it at the end. Any help would be appreciated.

Play around with this:

Dim strText As String
Dim docTarget As Document
Dim rgeDocTarget As Range

strText = "This String!"

Set docTarget = Documents.Open("C:\Your_Path\Document_Name.doc")
With docTarget
Set rgeDocTarget = .Range
rgeDocTarget.InsertAfter strText
.Close wdSaveChanges
End With


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org



Re: Insert a selection at the end of a Word Document by Greg

Greg
Mon Jul 10 14:34:14 CDT 2006

Rob,

Put something like the following in your command button code:

Private Sub CommandButton1_Click()
Dim myFile As Word.Document
Set myFile = Documents.Open(FileName:="C:\Test.doc")
With myFile
.Range.InsertAfter Me.TxtBox1 '(the textbox that holds the users
string input)
.Close SaveChanges:=wdPromptToSaveChanges
End With
Unload Me
End Sub



RoVo wrote:
> Hello,
> I am creating a userform that takes a string and adds it to the end
> of a different word file. For example, the current file has a text
> string inputted from the user via the form, and I need to take that
> string, then transfer it over to a existing file that already has text
> in it and paste it at the end. Any help would be appreciated.
>
> Rob