Remove text box of MS word document - c#

I have few MS word documents which contains text in text boxes. I want to remove those text boxes but keep the data as it. How can i do it ?

I think you can get hold of the text from inside the textboxes using something like ActiveDocument.Shapes(1).TextFrame.TextRange.Text and then you could delete it by doing something like ActiveDocument.Shapes(1).Delete, and after that you'd have to put the text you retrieved from the text box in the relevant part of the document.

Related

Over come placeholder text with innerText

What I want to do is to fill it with text programatically.
webBrowser1.Document.GetElementById("textBox").InnerText = "foo";
This code works but some websites have a placeholder text. This code will not allow me to fill this as value but instead it as a placeholder text.
Strangely in some text box, it will be paste as value when there are a placeholder text. But some text box it wont.
Another scenario is that when it is innerText is placed as a placeholder text, all I have to do is click on that text box and write something next to it. This will act as a text box values.
Is there another way around this?
You need to set the value attribute of the <input id='textBox'> elment not the innertext.
webBrowser1.Document.GetElementById("textBox").SetAttribute("value", "text text text");

WPF Textbox - How to save text without the wrapping-paragraph

I load some texts from a database with different lengths into a textbox. (From 1 character to 1000 words...)
I use TextWrapping="Wrap", so if the text is to big for the width of the textbox, it will create a new line....
By saving the text, the added paragraph from TextWrapping="Wrap" will also be saved. But I don't want this. The original text shouldn't be changed in any way...
How can I display the text on a new line in the textbox without adding a "real" paragraph?
Is there a way I can determine if the paragraph was added from TextWrapping="Wrap" or if it belong to the original text?
Thanks
As #StevenRands mentioned, the source text won't be changed in any way by using TextWrapping.
It only affects the display of the text inside the TextBox.
Normally if you used text Wrapping,it wont affect the original source text.But anyways Before saving back to database you can remove the new line constants from your text box text which will give you the original text loaded from db.

How to Preserve Formatting in a Multi-Line Text Box

I have a website where I create a textbox multi-line at runtime depending on some selections for example, they specify the number of lines and the width, then I create the textbox and put it in a panel on the next page. My issue is that in the textbox they would like to write something like this:
Company Name
123 Test Avenue
New York, NY 10001
I would like to preserve the formatting, what i mean by this is keeping the next lines as a block, right now if they entered it like that in the textbox it would show like this:
Company Name 123 Test Avenue New York, NY 10001
Is there a way at all to do this with <asp:TextBox/> multi-line ?.
You need to use a control like ckeditor . (Rich text editors for asp.net)
TextArea (asp:textbox with mode="multiline") does not save the formatting, which in your case is <br/>
To persist the rich text into the database you need to think of possible problem in advance.
How to save HTML data in Sql Server
how to save html to a database field
http://forums.asp.net/t/1669475.aspx/1

highlighting a text without using original text in lucene.net?

How can I highlight my searched text without using the original text in lucene.net? I just want to used an index and the text is indexed by using the field termvector with postion offsets?
if you index your field with "Store.YES" and "TermVector.WITH_POSTIONS_OFFSETS"
you can use FastVectorHighlighter in contrib to highlight search results without referencing original text.

How to read text that is present in text box of MS word document?

I have an word document which I want to convert to text (.txt) file programmatically. I am using C# for this.
I am able to read paragraphs and tables from word document and convert them to text. There are some textboxes in the word document and those textboxes contain text that I want to read and put them in text file.
My problem is I do not know in which collection those textboxes are stored. For example, all tables are stored in tables collection, paragraphs in paragraphs collection.
Can anyone please tell me how to read from these text boxes?
Please let me know if you need any additional information.
There are text boxes and text frames. I'm pretty sure any text inside text boxes will be part of the Doc.Content range.
To find all the text frames in a document, I use this VBA code:
Dim Doc As Document
Dim Range As Range
' Load document
Set Range = Doc.StoryRanges(wdTextFrameStory)
Do Until Range Is Nothing
' Do something with Range.Text
Set Range = Range.NextStoryRange
Loop

Categories

Resources