0

I have an issue while sending Whatsapp messages to my customers using excel vba, everything was working fine till I have updated the windows 10, then the code is broken

Option Explicit
Sub WhatsAppMsg()

Dim LastRow As Long
Dim i As Integer
Dim strip As String
Dim strPhoneNumber As String
Dim strMessage As String
Dim strPostData As String
Dim IE As Object

LastRow = Range("A" & Rows.Count).End(xlUp).Row

For i = 2 To LastRow

    strPhoneNumber = Sheets("Sheet1").Cells(i, 1).Value
    strMessage = Sheets("Sheet1").Cells(i, 2).Value
    ActiveSheet.Shapes(1).Copy
    
        
        strPostData = "whatsapp://send?phone=" & strPhoneNumber & "&text=" & strMessage
        Set IE = CreateObject("InternetExplorer.Application")
        IE.navigate strPostData
        
        Application.Wait (Now + TimeValue("00:00:05"))
                
                
        Call SendKeys("^v")

        Application.Wait (Now + TimeValue("00:00:05"))
        
        Call SendKeys("{ENTER}", True)
        

Next i

End Sub
  • See https://stackoverflow.com/questions/41553070/vba-internetexplorer-application-object-hang and https://stackoverflow.com/questions/54240485/windows-10-ie-is-not-working-with-old-vba-code – ed2 Sep 27 '21 at 12:49
  • I've tried the same method but did not work – Mohamed El Habchi Sep 28 '21 at 08:25
  • Okay, so for "code is broken", what do you mean exactly? Is there an error? What kind, and which line? Or is there some other non-error difference between your expected outcome and the actual outcome? (if so, describe specifics). For more information, see https://stackoverflow.com/help/minimal-reproducible-example and https://stackoverflow.com/help/how-to-ask, this helps the SO community help you. – ed2 Sep 28 '21 at 11:20
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 03 '21 at 16:44
  • when I run the code this error message will be shown 'Run-time'-2147023170 (800706be)': Automation error The remote procedure call failed' – Mohamed El Habchi Oct 12 '21 at 10:02

1 Answers1

0

I would confirm that you are logged into your WhatsApp account before running the Macro. I received a similar error when trying to populate PDFs from an excel macro. It turns out I wasn't logged into Adobe. Once I was logged into Adobe the error went away and the Macro ran as expected.