我正在尝试添加位于一系列单元格上的多个收件人的电子邮件。
我可以选择工作表上的电子邮件范围。
但是,我一直收到这个不匹配错误,我不知道如何解决它。
我一直在寻找解决方案并做了同样的步骤。
请原谅我,我是 VBA 新手。非常感谢您的帮助。我的代码如下,
Private Sub CommandButton1_Click()
Dim olapp As Object
Dim olmail As Object
Dim recip As String
lastr = ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
'this is for the range of data to be copied on the body but have yet to do it
lastr2 = ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 7).End(xlUp).Row
recip = ThisWorkbook.Sheets("Sheet1").Range("G3:G" & lastr2).Value
'mismatch after this step
Set olapp = CreateObject("Outlook.Application")
Set olmail = olapp.CreateItem(0)
With MItem
.to = recip
.Subject = "hello"
.Body = "whats up"
.display
End With
知道为什么会这样吗?