|
本帖最后由 duquancai 于 2018-6-13 15:48 编辑
有个奇葩问题:
标题:“投标人综合情况简介”,然而投标技术文件资料清单中:“投标人情况综合简介”,前后不一致!!!
害得我检查了“半天”!!!!- Sub main()
- Dim Dic As Object, myDoc As Document, tb As Table, c As Cell
- Set myDoc = ActiveDocument
- Set Dic = CreateObject("Scripting.Dictionary")
- Call getData(myDoc, Dic)
- If Dic.Count = 0 Then Exit Sub
- If myDoc.Tables.Count = 0 Then Exit Sub
- Set tb = myDoc.Tables(1)
- For Each c In tb.Columns(2).Cells
- With c.Range
- .End = .End - 1: sr = .Text
- If Len(sr) Then
- If Dic.Exists(sr) Then
- tb.Cell(c.Row.Index, c.Column.Index + 1).Range.Text = Dic(sr)
- End If
- End If
- End With
- Next
- MsgBox "OK!"
- End Sub
- Sub getData(Doc As Document, d As Object)
- Dim myStart&, n&, k$, t1&, t2&
- With Doc.Content.Find
- Do While .Execute("[一二三四五六七八九十〇百千]@.", , , -1)
- n = n + 1
- With .Parent
- If n > 1 Then
- t1 = Doc.Range(myStart, myStart).Information(1)
- t2 = Doc.Range(myStart, .Start).Information(1)
- d(k) = t1 & "—" & t2
- End If
- myStart = .Start: .Start = .End: .MoveEndUntil vbCr
- k = .Text: .SetRange .End, .End
- End With
- Loop
- End With
- If n > 0 Then
- t1 = Doc.Range(myStart, myStart).Information(1)
- t2 = Doc.Range(myStart, Doc.Content.End - 1).Information(1)
- d(k) = t1 & "—" & t2
- End If
- End Sub
复制代码 |
|