[英]How to find a value in each cell in Microsoft Word document?
I am trying to see if I can find the value in each cell on a Microsoft Word document between pages 9 and 15. When I get to the part where I am trying to set a range to search in, the Set Doc = wrdApp.Selection.Range
give me the error:我正在尝试查看是否可以在 Microsoft Word 文档的第 9 页和第 15 页之间找到每个单元格中的值。当我到达要设置搜索范围的部分时,
Set Doc = wrdApp.Selection.Range
给我错误:
Type Mismatch
类型不匹配
The Word document cannot be copied into Excel. Word 文档无法复制到 Excel 中。 The word document has to keep its formatting and someone built in some weird headers on each page with merged formatting etc.
word文档必须保持其格式,并且有人在每个页面上使用合并格式等内置了一些奇怪的标题。
Sub TFUpdate()
Dim Wd, FinalRow, TableRow
Dim wrdApp As Object
Dim DoC As Range
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open("C:\Users\kimbersr\Desktop\Word Project\TF1.doc")
wrdApp.Visible = True
ThisWorkbook.Worksheets("sheet2").Activate
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
TableRow = 1
x = 1
For i = 1 To FinalRow
part = Cells(i, 1).Value
wrdApp.Selection.GoTo What:=1, Which:=1, Count:=9
Set DoC = wrdApp.Selection.Range
wrdApp.Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=14
wrdApp.DoC.End = wrdApp.Selection.Bookmarks("\Page").Range.End
wrdApp.DoC.Find.Execute FindText:="14-581930L", Forward:=True
If wrdApp.DoC.Find.Found = True Then
wrdApp.DoC.Select
End If
Next i
End Sub
Too little information about the format/data of both the Excel and Word files.有关 Excel 和 Word 文件格式/数据的信息太少。
Based on the scarce amount of info ...I would probably simply copy the Word data tables to Excel an simply run the VLOOKUP or the INDEX MATCH combo on the 4th column.基于稀缺的信息量......我可能会简单地将 Word 数据表复制到 Excel,然后在第 4 列简单地运行 VLOOKUP 或 INDEX MATCH 组合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.