Click here to Skip to main content
15,916,215 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i have a word 2007 document , my word document have 4 text box control, i want to replace these text boxes with input strings in My apllication in c#,attention this ,i do not want to replace text type in word, i want to replace text box control of word document;



C#
FindAndReplace(varWord, @"#Sabbat_School#", Properties.Settings.Default.SchoolName);

 private void FindAndReplace(Word.Application wordApp,
                   object findText, object replaceText)
       {
           object matchCase = true;
           object matchWholeWord = true;
           object matchWildCards = false;
           object matchSoundsLike = false;
           object matchAllWordForms = false;
           object forward = true;
           object format = true;
           object matchKashida = true;
           object matchDiacritics = true;
           object matchAlefHamza = true;
           object matchControl = true;
           object read_only = false;
           object visible = true;
           object replace = 2;
           object wrap = 1;
           
           wordApp.Selection.Find.Execute(ref findText, ref matchCase,
               ref matchWholeWord, ref matchWildCards, ref matchSoundsLike,
               ref matchAllWordForms, ref forward, ref wrap, ref format,
               ref replaceText, ref replace, ref matchKashida,
               ref matchDiacritics,
               ref matchAlefHamza, ref matchControl);
       }


this code is replace #Sabbat_School# to Properties.Settings.Default.SchoolName in word documents , but it replace text and does not work in text box control in word,
i want a code that work in text box control in word. please help me
Posted
Updated 3-Aug-11 20:12pm
v3

1 solution

Hi I think you want to delete textbox in word document and write some text there.
You can do that using

SQL
ActiveDocument.Shapes("Text Box 2").Select
Selection.ShapeRange.Delete


and then write your text there...

Hope this will help you.
 
Share this answer
 
Comments
a.bolandnataj106 4-Aug-11 2:30am    
Thank you , but i want to replace the content of a text box control of word document
Suresh Suthar 4-Aug-11 2:44am    
Ok, Try Selection.TypeText after selecting the textbox.
a.bolandnataj106 4-Aug-11 3:04am    
It does not work :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900