gpt4 book ai didi

Excel VBA 发送短信到 Whatsapp

转载 作者:行者123 更新时间:2023-12-04 19:48:02 25 4
gpt4 key购买 nike

我设计了一个代码,可以将消息从 excel 发送到 WhatsApp 到联系人列表,它适用于单个联系人,但是当添加多个联系人时,它不会移动到该联系人,而是粘贴其他联系人姓名 &第一个联系人的消息框中的消息。这是 excel View ,当我按下按钮时,Whatsapp 网页的输出确实如图片所示那样工作。

enter image description here

我知道有一些小错误,但非常感谢任何对解决此问题的支持。这是代码

Sub Test()

Dim text As String
Dim contact As String
text = Range("C2").Value
ActiveWorkbook.FollowHyperlink Address:=" https://web.whatsapp.com/"
If MsgBox("Is WhatsApp Loaded?" & vbNewLine & vbNewLine & "Press No To Cancel", vbYesNo + vbQuestion + vbSystemModal, "WhatsApp") = vbYes Then
Fazer (100)
startrow = 2
startcol = 2
Do Until Sheets(1).Cells(startrow, 1) = ""
contact = Cells(startrow, 1)
text1 = Sheets(1).Cells(startrow, startcol).Value
Fazer (3000)
Call SendKeys("{TAB}", True)
Fazer (1000)
Call SendKeys(contact, True)
Fazer (1000)
Call SendKeys("~", True)
Fazer (1000)
Call SendKeys(text1, True)
Fazer (1000)
Call SendKeys("~", True)
Fazer (1000)
startrow = startrow + 1
Loop
Else
End If
End Sub

Function Fazer(ByVal Acao As Double)
Application.Wait (Now() + Acao / 24 / 60 / 60 / 1000)
End Function


最佳答案

您还可以使用 WhatsApp API 并避免打开 wpp web(在 ActiveWorkbook.FollowHyperlink Address:="https://web.whatsapp.com/" 中),大量的“sendkeys”和“wait”方法。

下载:

https://www.whatsapp.com/download

在“加载”手机的情况下使用 InternetExplorer 和 API,电话号码的链接不应包含特殊字符(查看文档)

看这个简单的例子:

Sub wpp()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application") 'Create object IE
IE.navigate "whatsapp://send?phone=5511912341234&text=something" 'Send message "something" to this phone (Brazil)
Application.Wait Now() + TimeSerial(0, 0, 3) 'ok just one wait and sendkeys :v
SendKeys "~"
'IE.Quit 'The navigate already kills the IE
Set IE = Nothing 'Clear the object
End Sub

关于Excel VBA 发送短信到 Whatsapp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62482567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com