- Sub 粘贴word_芐雨()
- Dim wdApp
- Set wdApp = CreateObject("word.application")
- Application.ScreenUpdating = False
- Set sht = ActiveSheet
- wdpath = ThisWorkbook.Path & "\new_fortune.docx" '文档路径
- ' On Error Resume Next
- Set wDoc = wdApp.documents.Open(wdpath)
- wDoc.Tables(1).Select
- wDoc.ActiveWindow.Selection.Copy
- sht.Activate
- sht.[G1].Select
- sht.PasteSpecial Format:="Unicode 文本", Link:=False, DisplayAsIcon:=False
- wdApp.Quit
- Set wdApp = Nothing
- Call t
- MsgBox "完成!!!!"
- Application.ScreenUpdating = True
- End Sub
- Sub t()
- Dim brr(1 To 3000, 1 To 4)
- arr = [G1].CurrentRegion
- On Error Resume Next
- For i = 1 To UBound(arr)
- tmp = Replace(Replace(Replace(StrConv(arr(i, 2), 4), "[微博]", ""), "等)", ")"), " ", "")
- s = Split(tmp, ";")
- For j = 0 To UBound(s)
- t1 = arr(i, 1)
- If InStr(s(j), "名:") > 0 Then
- S2 = Split(s(j), "名:")
- t2 = Mid(S2(0), 2)
- If InStr(S2(1), "研究小组(") > 0 Then
- s3 = Split(S2(1), "研究小组(")
- t3 = s3(0)
- s4 = Split(Split(s3(1), ")")(0), "、")
- For n = 0 To UBound(s4)
- x = x + 1
- brr(x, 1) = t1
- brr(x, 2) = t2
- brr(x, 3) = Replace(t3, ":", "")
- brr(x, 4) = s4(n)
- Next
- Else
- If InStr(S2(1), "证券") > 0 Then
- s3 = Split(S2(1), "证券")
- t3 = s3(0) & "证券"
- x = x + 1
- brr(x, 1) = t1
- brr(x, 2) = t2
- brr(x, 3) = Replace(t3, ":", "")
- brr(x, 4) = Replace(s3(1), ":", "")
- Else
- s3 = Split(S2(1), "公司")
- t3 = s3(0) & "公司"
- x = x + 1
- brr(x, 1) = t1
- brr(x, 2) = t2
- brr(x, 3) = Replace(t3, ":", "")
- brr(x, 4) = Replace(s3(1), ":", "")
- End If
- End If
- End If
- Next
- Next
- Range("A2:D" & Rows.Count).Clear
- Range("G:H").Clear
- Range("A2").Resize(x, 4) = brr
- End Sub
代码放入excel中,两个文件必须在同一路径中,你测试一下
粘贴word_芐雨.zip
(40.72 KB)
本附件包括:- new_fortune.xlsm
- new_fortune.docx


雷达卡



京公网安备 11010802022788号







