gpt4 book ai didi

excel - 为什么在此v​​ba脚本中出现不匹配错误?

转载 作者:行者123 更新时间:2023-12-03 08:17:51 26 4
gpt4 key购买 nike

在“EmailItem.To = Str(Sheet4.Cells(1,2))”行上,当我尝试运行它时,出现不匹配错误,我该如何解决?
这是代码

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需要一个数字参数。您在考虑 CStr()吗?

关于excel - 为什么在此v​​ba脚本中出现不匹配错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63949681/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com