|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码放于 “WORD乙.docx”模块中》》》》》》》》》》》》》》》》》》》》》
Sub test()
Dim Q As Range, Ip As InlineShape, Doc As Document
Dim d As Object, myRow As Row, tDoc As Document
Set tDoc = ThisDocument
Set Doc = Documents.Open(tDoc.Path & "\WORD甲.docx", Visible:=0)
If Doc.InlineShapes.Count = 0 Then Exit Sub
Set d = CreateObject("Scripting.Dictionary")
For Each Ip In Doc.InlineShapes
Set Q = Ip.Range.Previous
With Q.Paragraphs(1).Range
.End = .End - 1
d(Replace(.Text, " ", "")) = .Information(1)
End With
Next
Doc.Close 0
For Each myRow In tDoc.Tables(1).Rows
s1 = myRow.Range.Cells(1).Range.Text
s2 = myRow.Range.Cells(2).Range.Text
s1 = Replace(Split(s1, Chr(13) & Chr(7))(0), " ", "")
s2 = Replace(Split(s2, Chr(13) & Chr(7))(0), " ", "")
If d.Exists(s1 & s2) Then
myRow.Range.Cells(3).Range.Text = "WORD甲中第 " & d(s1 & s2) & " 页"
End If
Next
End Sub
|
|