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

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 :
Kindly add the title to you article,
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
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.

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)

Related

Bold or italicize section of text in MS Access report text box

Is there anyway to make a section of text in a report text box stand out? It can be bold, italicized, underlined, highlighted.. Anything to make it stand out more than the rest of the text in the same text box.
The text to be manipulated would be enclosed with *** on both sides.
I am on MS Access for Office 365 - 16.0.10730.20264 32bit
The code behind that button is here.
Private Sub Command20_Click()
Me.Text18.Value = Me.Text15.Value
End Sub
The Text15 is the Rich Text Box and the Text18 is plain text. When you go to set the value of the rich text box in code (Text15 in this example) you'll need to write out exactly to what you see in the right depending on what you need.

Wrong barcode exported from Visual Basic Macro in MS Word to PDF

I am trying to export through a Macro in MS Word a String that has 4 numbers. The whole Macro runs just fine, but, when I open the resulting PDF, I see that the barcode displayed seems corrupt.
This is the result:
In the Macro, I select the text I want to format, and change the font to "Free 3 of 9 Extended".
I have tried wrapping this number with "*" characters without success. Also tried "!". None of this seems to work. The funny part is that, if I open a Word document and type the same numbers using the same font, a clear Barcode is displayed:
This is what I see when writing directly in MS Word the same characters using the same font,this is what I see (which is what I want to achieve in the PDF export).
My macro exports to PDF with the following code:
Public Function guardar(id As String) As String
Dim path As String
guardar = id
obj_Word.ActiveDocument.ExportAsFixedFormat OutputFileName:=guardar,
OptimizeFor:=wdExportOptimizeForPrint, UseISO19005_1:=True,
IncludeDocProps:=True, KeepIRM:=True, ExportFormat:=wdExportFormatPDF
End Function
Is it possible that the template you are given is setting the font weight to bold in that portion of the document in which you are introducing the barcode, thus modifying the way it is displayed?
I cannot think of any other reason. The code you are posting does not seem to be the culprit.

RichEditBox loses formatting for empty text

I have something like a diagramming UWP application where each shape has an RichEditBox. The problem is, that I loose the formatting when the text is empty.
For Example:
Change the text to bold: EditBox.Document.Selection.CharacterFormat.Bold = FormatEffect.On.
Delete all text
Get the text via "EditBox.Document.GetText(GetTextFormat.FormatRtf, out text);
=> The result is just an empty string, not valid RTF document at all. This is a problem in my scenario. Is there an approach to solve it? I think RichEditBox should always provide a valid RTF document.

Convert Crystal Reports Text Object/Text box to HTML?

I want to convert the text from Crystal reports to HTML and so far I have noticed that if I simply add a text field, I am able to change it to HTML by formatting text option and then under Paragraph tab there is an option to change the text interpretation. The problem is that I have entered text box to enter some hard coded information along with the database driven field, so I would like to know if there is a way I can convert the text box data into HTML. I am currently using crystal reports XI and want going forward want to upload these reports in a website using visual studio 2010. Thank you for your help.
It appears that the 'Text Interpretation' is ONLY a property of these fields:
Database
Formula
Parameter
Group Name
I wasn't able to get the Text Object to act as HTML.
However, you could create a formula with static HTML text:
"<strong>this is bold text</strong>"
Or a formula that combines text w/ data:
"<pre>" + {table.html_field} + "</pre>"
You could also use a string parameter to display user-supplied, HTML text.

Formatting text from Mulitline text box in word with VBA

I'm putting together a template in Word, using a form for the user to fill in to then populate some of the document.
The bit I'm currently stuck on is at the end of the document, where the cc's are listed.
The form has a multiline text box into which the user puts in their cc's, one per line.
I then want to add to the end of the document the contents of the text box, but in the right format. Specifically, it should look like:
cc: First CC contact
Second CC contact
so on and so forth
I attempted to do this using 2 bookmarks, so my code currently is:
' If 'CC' box has content, add it
If doc_CC.TextLength > 0 Then
.Bookmarks("CC").Range.Text = vbCr + "cc:"
.Bookmarks("CCs").Range.Paragraphs.Indent
.Bookmarks("CCs").Range.Text = doc_CC + vbCr
End If
However, when this is run, on the page it looks like:
cc: first contact
second contact
and so on
Realise that the 2 bookmark method is a bit messy but it seemed like a good idea at the time - obviously this is not the case! Have done some searching for a way to do it with Split but am not making much progress down this path - suspect I'm googling for the wrong thing.
How do I do this so that the formatting is as desired? Any help is greatly appreciated.
Try inserting a tab character? + Chr(9) or even + vbTab may work.
Have found a work around which, while doesn't answer the actual question of how to do it, does produce a result to the same effect.
Have used a 2 column table without no lines instead with contents of a1 being "cc:" and contents of a2 being whatever was entered into the multiline text box. If there is nothing in the text box, then the table is deleted.
I'll keep on eye on this question though so if some one does have the proper answer I can mark it accordingly.
Another possibility would be to format the cc paragraph with a hanging indent (like is used for bullets or numbering). Use a newline character - Chr(11) - instead of vbcr to separate each entry. The text should all line up,then...