Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

I am using blow code to insert textbox in ms-word document. It inserts all the textboxes in one page i want to start a new page when end of page occurs.


C#
using Microsoft.Office.Interop.Word;
using System.Data;
using Microsoft.Office.Core;

float top = 20;
float height = 250;

Document wrdDoc;
Microsoft.Office.Interop.Word.Application app;
app = new Microsoft.Office.Interop.Word.Application();
app.Visible = true;
wrdDoc = app.Documents.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);

for (int i = 0; i < 25; i++){
Microsoft.Office.Interop.Word.Shape textbox = wrdDoc.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 20, top, 250, height);

textbox.TextFrame.TextRange.Text = "VSTO" + i.ToString();

top += height + 20;}
Posted

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