是否可以在 Word 2007 的一个书签中插入多个表格。我有模板 Word 文件,书签在文件中间。每张桌子后我都需要分页符。我的代码似乎将所有表格插入到前一个表格的左上角单元格中。我使用 VS2008 (3.5)。
{ Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
object bookmark = "Tables"
oDoc = oWord.Documents.Open(ref fileName,
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, ref missing, ref missing);
var oJ = from o in dbcontext.Org_Jedinica
select o;
Word.Table oTable;
Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref bookNaziv).Range;
foreach (var orgJedinica in oJ)
{
oTable = oDoc.Tables.Add(wrdRng, 24, 2, ref oMissing, ref oMissing);
oTable.Cell(1, 1).Range.Text = "..."; ...
}
}