关闭选项卡,然后再继续

时间:2019-02-02 20:46:29

标签: excel vba sendkeys

这为每个语句是发送经由的WhatsApp使用WhatsApp的API链接传递消息个性化的Excel宏的一部分。发送完每条消息后,我需要关闭该标签,以免最终导致打开大量标签的Chrome出现。

For x = 2 To uf
telwhatsapp = a.Cells(x, "B")
textwhatsapp = a.Cells(x, "C")

mylinkwhatsapp = "https://api.whatsapp.com/send?phone=" & telwhatsapp & "&text=" & textwhatsapp
ActiveWorkbook.FollowHyperlink mylinkwhatsapp

Application.Wait (Now + TimeValue("00:00:05"))
ActiveWindow.Application.SendKeys "{TAB}"
Application.Wait (Now + TimeValue("00:00:01"))
ActiveWindow.Application.SendKeys "{TAB}"
Application.Wait (Now + TimeValue("00:00:05"))
ActiveWindow.Application.SendKeys "(~)" 'énvia enter para enviar mensaje
Application.Wait (Now + TimeValue("00:00:18"))
ActiveWindow.Application.SendKeys "(~)"
Next x
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

我尝试在Next x之前添加它,但没有成功

ActiveWindow.Application.SendKeys "{%F4}"

在Next x都不起作用之前也尝试过

ActiveWindow.Application.SendKeys "{^F4}"

任何帮助与未来的Excel行继续之前关闭标签?

1 个答案:

答案 0 :(得分:0)

尝试仅使用%{F4}而且,在调用sendkey时,您应该这样做Application.SendKeys "%{F4}", True,以便excel等待sendkey完成执行。

我希望对您有帮助