Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hellow
i want to write a text inside a textbox that i have created in ms word(programably by c#)
C#
xShape  = oDataDoc.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 1, 1, 75, 50, ref rng);
object ss2=(object)xShape;
xShape.Select(ref ss2);

using the above code i had to close my c# program in order to make the textbox active in word document so i can write my text inside it
OR
i have to press in the mouse anywhere on the document in order to make it active
BUT MAY BE ANOTHER SOLUTION
if i could insert a bookmark(B1) inside this textbox using
C#
book1 = oDataDoc.Bookmarks.Add("B1", ref ss2);//<--- did not worked i get type mismatch

the 2nd paramter is my problem, how could i get range of the textbox ?
Posted

1 solution

i have found the solution
C#
xShape = YourDocument.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 1, 1, 75, 50, ref rng);//.Name;
xShape.TextFrame.TextRange.Text = "Code Project";
 
Share this answer
 
v4

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