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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting text in Word where there's already text.

Status
Not open for further replies.

djsslp

Technical User
Jul 5, 2001
5
US
New to VBA...very new!

I need to know how to insert text coming from a userform onto an existing Word doc. The amount of text may be different each time according to the choices the user makes. The text needs to be inserted between existing text on the doc. EX:

"existing text existing text existing text"
{insertion of text line here, and possibly more lines to
be inserted}

"existing text existing text existing text"

The existing text above and below where the lines of text is to be inserted needs to expand or collapes according to how many lines of text the user chooses. I've tried every way I know how and still can't insert the text the way I want it...please help! Thanks in Advance!

djsslp X-)
 
*The text needs to be inserted between existing text on the *doc. EX: "existing text existing text existing text"


Hi, i think that is a good choice to read in 1st instance the word document line by line, in this thread you have a function to do that thread707-140588 I have some automation functions to seek data in the Word Document. Now i dont have that functions in my memory, soon i wiil get into my MEMO Sheet and i will post that information.

*I need to know how to insert text coming from a userform *onto an existing Word doc. The amount of text may be *different each time according to the choices the user makes

A way to do that is to merge the Fields into a Merged Word Doc to The Table or Query, the you can use a simple function to automate with the Word Document. If you seek in this access foruns you will get something for shure.

Hope it helps
Best Regards

---
JoaoTL
NOSPAM_mail@jtl.co.pt
 
hi,

A simple way to do this is

Dim WRD as Word.Application

Public Sub FindReplace()

With wrd.ActiveDocument.Range(Start:=0, End:=0).Find
.Text = "existing text"
With .Replacement
.Text = "replacement text"
End With
.Execute Replace:=wdReplaceAll, Format:=True, MatchCase:=True, _
MatchWholeWord:=True
End With

End Sub

Hope this solves ur problem

Cheers!!!
Niraj >:):O>

 
Thanks UFObaby!

That helps out a lot, especially for other things that I am doing.

djsslp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top