在特定页面中的位置范围以创建表

时间:2014-08-14 13:20:35

标签: c# ms-word range interop

我试图在我的word文档中将表放在第二页的特定位置,但总是会出错。我的数据库中有范围,从1049开始到1420结束。

当我输入这些值时,我收到Out of Range Value错误。我怎样才能把桌子放在我想要的地方?

这是我的代码的一部分:

ApplicationClass wordApp = new ApplicationClass();
Document adoc = wordApp.Documents.Open(ref path, ref missing, ref readOnly, ref     missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

Microsoft.Office.Interop.Word.Table wordTable = null;

object rangeStart = null;
object rangeEnd = null;
Microsoft.Office.Interop.Word.Range rngBold = null;

rangeStart = Int32.Parse(lstTables[1].RNG_STA.ToString()); // 0 - with zero works but    put in the beggining 
rangeEnd = Int32.Parse(lstTables[1].RNG_END.ToString()); // 0 - with zero works but put    in the beggining

rngBold = adoc.Range(ref rangeStart, ref rangeEnd);

wordTable = adoc.Tables.Add(rngBold, lstTables[1].TOTALLIN, lstTables[1].TOTALCOL, ref missing, ref missing);

0 个答案:

没有答案