|
借用网上的一段微信群发文本的VBA,如何修改成群发文件?
Sub sendall()
nowrow = Selection.row() - 3
endrow = Sheet2.Cells(Rows.Count, 1).End(xlUp).row - 3
For i = 0 To endrow:
If Cells(i + 3, 1).Value <> "" Then
Call sendmessages(i)
End If
Next
End Sub
Sub sendmessages(ByVal row As Integer)
i = row
Set ws2 = CreateObject("wscript.shell")
ws2.AppActivate "微信"
ws2.SendKeys "^%w"
Set ws2 = Nothing
Rem 正在执行 cells(3+i,1)
Name = Cells(3 + i, 2).Value
Msg = Cells(3 + i, 3).Value
Set ws = CreateObject("wscript.shell")
ws.Run "mshta vbscript:ClipboardData.SetData(" & Chr(34) & "text" & Chr(34) & "," & Chr(34) & Name & Chr(34) & ")(close)", 0, True
Sleep 999
ws.SendKeys "^f"
Sleep 999
ws.SendKeys "^v"
Sleep 999
ws.SendKeys "{ENTER}"
Sleep 555
ws.SendKeys "{TAB}"
Sleep 555
ws.Run "mshta vbscript:ClipboardData.SetData(" & Chr(34) & "text" & Chr(34) & "," & Chr(34) & Msg & Chr(34) & ")(close)", 0, True
Sleep 500
ws.SendKeys "^v"
Sleep 300
ws.SendKeys "{ENTER}"
Set ws = Nothing
End Sub
|
|