为什么有时粘贴而其他时候不粘贴?

时间:2020-03-11 02:26:47

标签: excel vba

我正在使用以下代码,以便将通讯组列表,主题行和电子邮件正文复制/粘贴到Internet Explorer中打开的电子邮件中。

大约80%的时间它将完美地复制/粘贴所有内容。其他时候主题或分发都无法粘贴。如果有人能给我一个更好的方法来做到这一点,那就太棒了!

'These code is for the distro line
Sheets("Setup").Range("F8").Copy
Sheets("Main Email Work Area").Select
SetForegroundWindow HWNDSrc
Set tags = ie.Document.GetElementsByTagName("input")
tags(0).Click
tags(0).Focus
Application.SendKeys ("^v"), True
Application.Wait Now + TimeValue("00:00:01")


'This code sets the subject line
Sheets("Main Email Work Area").Select
Range(Cells(7, "J"), Cells(7, "M")).Select
Selection.Copy
SetForegroundWindow HWNDSrc
tags(3).Click
tags(3).Focus
Application.SendKeys ("^v"), True
Application.Wait Now + TimeValue("00:00:01")


'This code sets the email body
Sheets("Main Email Work Area").Select
emailBodyCopy = 120
While Cells(emailBodyCopy, "J").Value = ""
       emailBodyCopy = emailBodyCopy - 1
Wend
Range(Cells(emailBodyCopy, "J"), Cells(13, "L")).Select
Selection.Copy

SetForegroundWindow HWNDSrc

Set bodyarea = ie.Document.GetElementsByClassName("allowTextSelection _mcp_32 customScrollBar ms-bg-color-white ms-font-color-black owa-font-compose")
bodyarea(0).Click
bodyarea(0).Focus
Application.SendKeys ("^v"), True
Application.Wait Now + TimeValue("00:00:01")

0 个答案:

没有答案
相关问题