We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

change content of wtextbox

Thread ID:

Created:

Updated:

Platform:

Replies:

141663 Dec 26,2018 08:25 AM UTC Jan 7,2019 12:23 PM UTC WinForms 5
loading
Tags: DocIO
AAYADI
Asked On December 26, 2018 08:25 AM UTC

GoodMorning,
i have a wtextbox in my footer and i want to add text in ,

For Each sec As WSection In a.Sections
            For Each elem As Entity In sec.HeadersFooters.Footer.ChildEntities
                If TypeOf elem Is WParagraph Then
                    Dim para As WParagraph = elem
                    For Each ele As Entity In para.ChildEntities
                        If TypeOf ele Is WTextBox Then
                            Dim txt As WTextBox = ele
                            txt.TextBoxBody.LastParagraph.AppendText("Message")
                            txt.TextBoxFormat.FillColor = Color.Red
                        End If
                    Next
                End If
            Next
        Next


the color change in the second page and not in the first, but there is no text in the shape.



Dilli Babu Nandha Gopal [Syncfusion]
Replied On December 26, 2018 04:49 PM UTC

Hi Aayadi, 
 
We suspect that the reported problem might be due to the formats used in the input Word document. So, could you please provide us the input Word document used to reproduce the exact problem at our side. This will be more helpful to analyze further and provide you the appropriate solution at the earliest.

Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face. 
 
Regards, 
Dilli babu 


AAYADI
Replied On December 27, 2018 08:32 AM UTC

Hello,
here is the attached document,
the document contains two footers, and I can not write in the textbox of both footer.
the second thing is that I have a bookmark and in this bookmark i would just change the word between <*>
thanks a lot for your help.

Attachment: Files_ea205a28.zip

Dilli Babu Nandha Gopal [Syncfusion]
Replied On January 3, 2019 07:33 AM UTC

Hi Aayadi, 
 
Regarding I cannot write in the textbox of both footer:
On further checking in the input Word document, the textbox in first page is in the first page header and the textbox in second page is in the odd footer. So, the reported problem occurs at your end, when add text in odd footer.

In the Word document, there are multiple Headers and Footers. To achieve your requirement, we suggest you to iterate into all headers and footers of each sections and then add the text in textbox. 
 
 
To know more about working with headers and footers, kindly refer the following link.
https://help.syncfusion.com/file-formats/docio/working-with-sections#working-with-headers-and-footers
 

Regarding i would just change the word between <*>:
     1. If your requirement is to replace the text with some other text means, we suggest you to use find and replace functionality of DocIO.
    2. If your requirement is to replace the text with some dynamic values (values obtained in run time or from database), we suggest you to use mail merge functionality of DocIO. To execute mail merge in the Word document, it is need to change the place holder text as merge field and then execute mail merge using DocIO.

Please refer the below links to know more about working with Word document using DocIO:
Find and replace functionality in DocIO
Working with mail merge
Online sample for mail merge functionality 
 

Also, we have prepared a sample application to achieve your requirement using the given Word document. Please find the sample from the below link:
Sample link:
http://www.syncfusion.com/downloads/support/forum/141663/ze/Sample-879647397 

In this sample, we have done the following things:
1. Loads an existing Word document.
2. Iterates into headers and footers and get the textbox.
3. Add text and fill color in textbox.
4. Replace the text using Replace API of DocIO.
5. Saves the Word document.
 
 
Regards, 
Dilli babu. 


AAYADI
Replied On January 3, 2019 12:39 PM UTC

Hi Dilli,
thanks for the answers
for the textbox, i use your code but there is not box at the first page,
and to change the content between < > in a bookmark i use this code but it's not working.
then bookmark is like this
[hello mr <name>]



        Dim a As New WordDocument(chemin + "\testword\etpdp.doc")
        Dim bknav As BookmarksNavigator = New BookmarksNavigator(a)
        bknav.MoveToBookmark("hello")
        Dim tbp As TextBodyPart = bknav.GetBookmarkContent
        'Dim table As WTable = tbp.BodyItems(0)
        For Each item As Entity In tbp.BodyItems
            If TypeOf (item) Is WParagraph Then
                Dim existe As TextSelection = CType(item, WParagraph).Find(New System.Text.RegularExpressions.Regex("<name>"))   
                If Not existe Is Nothing Then
                    CType(item, WParagraph).Replace(existe.SelectedText, "AAYADI", True, False)
                End If
            End If
        Next


Dilli Babu Nandha Gopal [Syncfusion]
Replied On January 7, 2019 12:23 PM UTC

Hi Aayadi,

Thank you for your patience.

Regarding Text box is not found in the first page:

Since the text box is floating, text box is preserved at right side corner of the output Word document at our end. 
Please find the output screen shot:
 
Regarding Bookmark content is not replaced:

We have modified the code example and input Word document (included name bookmark) in the sample. Please find the modified sample in below link:
http://www.syncfusion.com/downloads/support/forum/141663/ze/MODIFI~11114279238  
 
 
The content is replaced with an angular bracket in above sample, if you require angular brackets kindly append the brackets as a string in Replace code snippet.

Please refer the code snippet with angular brackets 
 
CType(item, WParagraph).Replace(existe.SelectedText, "<" + "AAYADI" + ">", True, False)  
 
Please let us know if you have any questions.  

Regards, 
 
Dilli babu. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;