如何在VSTO中以编程方式创建表行? [英] How do you Create Table Rows programatically in VSTO?

查看:149
本文介绍了如何在VSTO中以编程方式创建表行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

 

如何使用VSTO将新的数据行添加到Word表中?

How do I go about adding a new row of Data to a Word Table using VSTO?

我正在Visual Studio 2008 for Word 2007中进行开发.项目类型为Word文档.我查看了MSDN参考,但没有用.

I'm developing in Visual Studio 2008 for Word 2007. The project type is Word Document. I looked at the MSDN reference but it didn't work.

所以任何人都可以给我举个例子.

So could anyone please give me examples of how to do so. 

谢谢

-Diran

推荐答案

嗨Diran,

Hi Diran,

下面是添加表然后插入新行的示例.

Below is a sample for adding a table and then inserting a new row.

希望有帮助


  Sub AddTable()
    Dim doc As Word.Document = wApp.ActiveDocument
    doc.Tables.Add(Range:=wApp.Selection.Range, NumRows:=1, NumColumns:= _
      2, DefaultTableBehavior:=Word.WdDefaultTableBehavior.wdWord9TableBehavior, AutoFitBehavior:= _
      Word.WdAutoFitBehavior.wdAutoFitFixed)
    wApp.Selection.InsertRowsBelow() 'adds row below current row
  End Sub


这篇关于如何在VSTO中以编程方式创建表行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆