[英]Why am I getting a mismatch error in this vba script?
On the line "EmailItem.To = Str(Sheet4.Cells(1, 2))" when i try to run it it comes up as a mismatch error how would i fix this?在“EmailItem.To = Str(Sheet4.Cells(1, 2))”这一行上,当我尝试运行它时,它显示为不匹配错误,我该如何解决?
Here is the code这是代码
Sub SendEmail_Example1()
Dim EmailApp As Outlook.Application
Dim Source As String
Set EmailApp = New Outlook.Application
Dim EmailItem As Outlook.MailItem
Set EmailItem = EmailApp.CreateItem(olMailItem)
EmailItem.To = Str(Sheet4.Cells(1, 2))
EmailItem.CC = "marcusburr@gmail.com"
EmailItem.Subject = "Test Email From Excel VBA"
EmailItem.HTMLBody = "Hi," & vbNewLine & vbNewLine & "This is my first email from Excel" & _
vbNewLine & vbNewLine & _
"Regards," & vbNewLine & _
"VBA Coder"
EmailItem.Send
End Sub
EmailItem.To = Str(Sheet4.Cells(1, 2))
Str
expects a numeric argument. Str
需要一个数字参数。 Are you thinking of CStr()
?你在想
CStr()
吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.