Processing
 

My vb.net code just replaces specified string by contents of rich text box. But I want to replace it with alignment also

19/09/2016 12:48#1

Joined at: 6 months ago

Post: 1

Thank: 0

Thanked: 0

I need to replace a specific string in a MS Word with text of Rich Text Box. I have achieved my that using the following code.

objDoc.Content.Find.Execute(FindText:="Comments1", _                                 ReplaceWith:=COMMENTS.Text, _ Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll) 

But, What my actual requirement is.. I want to replace it by exact text of rich text box with alignment.

For example :

  1. Kindly add the title to you article,
  2. Kindly add the abstract to your article

the above text is the content of rich text box.

But, in my word document it replaced as

  1. Kindly add the title to you article, 2. Kindly add the abstract to your article

Have you noticed that ? After the 1st point I have hit enter key and then only I have give 2nd point.

But, resultant text are concatenated with the 1st point.

So, what to do to get exact text with alignment of rich text box in my word document.

19/09/2016 14:05Top#2

MJH

Member

Joined at: 11 months ago

Post: 4

Thank: 0

Thanked: 0

I seem to recall something about Rich Text Box using vbLf for line feeds instead of vbCrLf, which I believe is what MS Word would expect to be used for a line feed. You might try something like this (air code):

objDoc.Content.Find.Execute(FindText:="Comments1", _                             ReplaceWith:=COMMENTS.Text.Replace(vbLf, vbCrLf), _ Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll) 
Similar articles

VBA regex matching over two lines

6 months ago - Reply: 1 - Views: 44

Table output to Word-2011 from Rstudio using knit

6 months ago - Reply: 0 - Views: 48

Write a Collection of paragraphs into a new document

6 months ago - Reply: 1 - Views: 72

how to write paragraphs without show to document

6 months ago - Reply: 1 - Views: 67

numericals in word macro

6 months ago - Reply: 1 - Views: 46

Can not find proofing tools

6 months ago - Reply: 0 - Views: 3

Possible values for <w:outlineLvl> in Word OOXML

6 months ago - Reply: 1 - Views: 8

C# restrict editing partial word paragraph

7 months ago - Reply: 2 - Views: 146

Macro translation Please (possible virus)

6 months ago - Reply: 1 - Views: 35

Doc/Docx Fastest Reading Method for Searching

6 months ago - Reply: 0 - Views: 3

Save embedded file / content from word

6 months ago - Reply: 0 - Views: 6

Counting words in Word document, including footnores

6 months ago - Reply: 1 - Views: 24

c# access extract word ole object

6 months ago - Reply: 1 - Views: 25

Using word wildcards to find unaccepted changes

6 months ago - Reply: 1 - Views: 46

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re