我有一个表,我选择了两列并将选择标记为书签?现在如何使用C#删除它?
我的代码是这样的:
/// <summary>
/// Delete all columns of specific bookmark
/// </summary>
/// <param name="bookmark"></param>
public void DeleteTableColumns(string bookmark)
{
object oBookmark = bookmark;
if (doc.Bookmarks.Exists(bookmark)) {
Range range = doc.Bookmarks.get_Item(ref oBookmark).Range;
//TODO:to be finished
}
}
答案 0 :(得分:0)
我已经知道如何解决这个问题,这是代码:
/// <summary>
/// Delete all columns of specific bookmark
/// </summary>
/// <param name="bookmark"></param>
public void DeleteTableColumns(string bookmark)
{
object oBookmark = bookmark;
if (doc.Bookmarks.Exists(bookmark)) {
object oCount = WdDeleteCells.wdDeleteCellsEntireColumn;
doc.Bookmarks.get_Item(ref oBookmark).Select();
app.Selection.Cells.Delete(ref oCount);
}
}