100求:word的VB程序中需要提取word中其中一个表格内的内容时怎样提取

来源:百度知道 编辑:UC知道 时间:2024/06/15 07:58:18
指的是一个表格内其中一个小格的内容要提取出来写在另一个地方,这个小格的内容怎样提取,急呀,帮帮忙~解决后马上给追加一百分

改表格的序号和单元格,你没有问题吧?

ActiveDocument.Tables(1).Cell(3, 3).Select
Selection.Copy
ActiveDocument.Tables(1).Cell(2, 2).Paste
ActiveDocument.Range(ActiveDocument.Paragraphs(1).Range.Start, ActiveDocument.Paragraphs(1).Range.Start).Select
Selection.PasteAndFormat wdFormatPlainText
解释:
Tables(1)取第一个表格,改数字为要取的表格
Cell(3, 3)取第3行第3列,改数字为要取的小格
Selection.Copy复制到剪贴板,

在第一个表格的第2行第2列粘贴

在本文档的第一个段落前粘贴 文本

楼上的代码不错,但是有几个细节好像有问题,我修改了一下:
Sub dyg()
ActiveDocument.Tables(1).Cell(3, 3).Select
Selection.Copy
ActiveDocument.Tables(1).Cell(2, 2).Select
Selection.Paste
ActiveDocument.Range(ActiveDocument.Paragraphs(1).Range.Start, ActiveDocument.Paragraphs(1).Range.Start).Select
Selection.PasteAndFormat(wdFormatPlainText)
End Sub

二楼的,请问如何知道是第几个表格?