wordDoc.Bookmarks.get_Item 集合所要求的成员不存在

c#在word中插入表格 代码:
public Word.Table InsertTable(string bookmark, int rows, int columns,float width)
{
object miss = System.Reflection.Missing.Value;
object oStart = bookmark;
Word.Range range = wordDoc.Bookmarks.get_Item(ref oStart).Range;//出错
Word.Table newTable = wordDoc.Tables.Add(range, rows, columns, ref miss, ref miss);
newTable.Borders.Enable = 1; newTable.Borders.OutsideLineWidth = Word.WdLineWidth.wdLineWidth025pt;
newTable.PreferredWidth = width;
newTable.AllowPageBreaks = false;
wordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;//水平居中
wordApp.Selection.Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//垂直居中
return newTable;
}
运行到Word.Range range = wordDoc.Bookmarks.get_Item(ref oStart).Range;时出错,,提示未处理COMException 集合所要求的成员不存在。
而且这边读取的bookmark是我以前传的bookmark,现在bookmark已经改了,但是还是以前的!
比如以前的是“名字”,现在改成“姓名”,但是读取的还是“名字”

请各位路过的高手不吝赐教一下!

第1个回答  2009-12-14
你可以重新生成一下试试本回答被提问者采纳