vba - VBA word macro to select indexed table cells
问题描述
I have one Word document containing 1 table. The table has 1 column and 190 cells, containing text, photos and mathtypes equations. I have a list of cell indexes in the current table, which I want to select via Visual basic for applications (VBA macro) and copy them to another document. For example, the list of indices is (1,3,7,9). The new document will contain:
the contents of cell 1, then move on to the next line
the contents of cell 3, then move on to the next line
the contents of cell 7, and so on
Is it possible to number the lines above as in the example below?
1) the contents of cell 1,
2) the contents of cell 3,
3) the contents of cell 7, ...
I found on the internet an example that, without experience in VBA, I could not develop:
Sub copyit()
Dim docOld As Document
Dim rngDoc As Range
Dim tblDoc As Table
If ActiveDocument.Tables.Count >= 1 Then
Set docOld = ActiveDocument
Set rngDoc = Documents.Add.Range(Start:=0, End:=0)
For Each tblDoc In docOld.Tables
tblDoc.Range.Copy
With rngDoc
.Paste
.Collapse Direction:=wdCollapseEnd
.InsertParagraphAfter
.Collapse Direction:=wdCollapseEnd
End With
Next
End If
End Sub
The "tblDoc.Range.Copy" statement needs to be replaced with cell selection, but I don't know how to proceed ... or how to number them!
解决方案
推荐阅读
- jquery - 如何使用jQuery ajax 重新加载用户不知道的页面是正在重新加载的页面?
- html - CSS样式表第一次没有链接到HTML web-dev
- android - 使用改造(pdf,ppt,png,jpg)“code = 500,内部服务器错误”上传文件有什么问题
- android - 如何绑定具有多个 IN 值的 SQL 语句?
- android - 如何使用导航视图
- c# - Net Core:用于数据检查的私有成员和数据注释之间的区别
- razorpay - 如何通过razorpay api取消特定用户(最终用户)的订阅
- python - TypeError: center() 最多接受 2 个参数(给定 4 个)
- javascript - 从 API.post() 函数调用 AWS 开发工具包检索 HTTP 响应
- c - “位掩码”条件未返回正确值