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

Remove Hard return from Word Doc

Status
Not open for further replies.

hexOffender

Programmer
Nov 6, 2006
146
US
I need to remove a hard return that was placed on each line of a word doc.
 
Wgat code do you have so far?

But since you will be using word interop this probably is a question better asked in the microsoft office forum on this site.

Christiaan Baes
Belgium

"My old site" - Me
 
hexOffender,

Try using the Selection object of Word Document e.g.

Code:
   With Selection.Find
      .Text = vbCrLf
      .Replacement.Text = String.Empty
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
   End With

   Selection.Find.Execute Replace:=wdReplaceAll

I'm assuming that you have instantiated Word Application and Word Document objects successfully.

Hope it helps.

 
Actually I guess I wasnt very clear, i'm sorry.
I am taking txt files that have a hard return in them for each line, then I am dumping them to word. so im not even using Word Interop. Im just using a rtfBox on a form
 
That's why it is always good to shows us some code that you already have. I think you need something like this

Code:
Dim s as string
'fill string from txt file via streamreader
s.remove(controlchars.crlf)



Christiaan Baes
Belgium

"My old site" - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top