You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Excel向WhatsApp Desktop发消息时报错2147023170(800706be)如何解决

错误原因

错误代码2147023170 (800706be)对应远程过程调用失败,确实由近期Windows系统更新触发:微软已正式停止对Internet Explorer的支持,系统更新后禁用了IE COM对象对非http/https类自定义协议(如whatsapp://)的调用权限,所以IE.navigate调用自定义协议时会抛出该错误。

修复方案

直接弃用IE对象调用协议,改用Windows原生的ShellExecuteAPI来唤起WhatsApp桌面端,兼容性更强,不需要依赖已停用的IE组件。

步骤1:在VBA模块顶部声明API

将以下代码粘贴到你现有代码的最顶部(所有Sub过程之前),兼容32位/64位Office:

#If VBA7 Then
Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
#Else
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#End If

步骤2:替换原有业务代码

修改后的完整发送逻辑如下:

Sub TextOnly()
    Dim LastRow As Long
    Dim i As Integer
    Dim strPhoneNumber As String
    Dim strMessage As String
    Dim strPostData As String
    Dim TimeInterval As String
    
    LastRow = Range("A" & Rows.Count).End(xlUp).Row
    TimeInterval = "00:00:" & Sheets("Sheet1").Cells(1, 8).Value
    
    For i = 2 To LastRow
        strPhoneNumber = Sheets("Sheet1").Cells(i, 1).Value
        ' 对消息内容做URL编码,避免特殊字符、空格、中文导致发送异常
        strMessage = WorksheetFunction.EncodeURL(Sheets("Sheet1").Cells(i, 2).Value)
        strPostData = "whatsapp://send?phone=" & strPhoneNumber & "&text=" & strMessage
        
        ' 替换原有IE调用逻辑,直接用系统API唤起WhatsApp
        ShellExecute 0, "open", strPostData, vbNullString, vbNullString, 1
        
        Application.Wait (Now + TimeValue(TimeInterval))
        SendKeys "{ENTER}", True
    Next i
End Sub
额外说明
  • 如果使用Excel 2010及更早版本没有内置EncodeURL函数,替换为自定义URL编码函数即可
  • 如果出现SendKeys不生效的情况,可适当延长TimeInterval的时长,确保WhatsApp窗口完全加载后再触发回车发送
  • 该方案完全移除了IE依赖,不受后续Windows系统更新对IE的禁用策略影响,适配所有主流Windows版本

内容的提问来源于stack exchange,提问作者mahavir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 23:06:04