0
我有以下excel vba代碼,它將通過電子郵件發送我的工作表中的一系列地址。 Howeve,我正在尋找可能使用輸入框來確定我想要發送電子郵件的範圍。我碰到的麻煩是讓輸入變成函數mailid理解的值。有什麼建議麼?excel vba inputbox
Sub EmailActiveSheetWithOutlook2()
Dim oApp, oMail As Object, _
tWB, cWB As Workbook, _
FileName, FilePath As String
Application.ScreenUpdating = False
'Set email id here, it may be a range in case you have email id on your worksheet
Sheets("Sheet1").Select
mailId = Range("b4:b5").Value
'Write your email message body here , add more lines using & vbLf _ at the end of each line
Body = "Hello, it appears you have not yet filled out the transportation contact information excel sheet. This sheet was emailed to you, please complete this and send to me saved as your firstnamelastname.xls at your earliest convience." & vbLf _
& vbLf _
& "Thanks & Regards" & vbLf _
& vbLf _
& "-Ryan " & vbLf _
「通過Outlook
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
.To = mailid
.Subject = "Transportation Committee Notice"
.Body = Body
'.Attachments.Add tWB.FullName
.send
End With
End Sub
chris-非常感謝你,我試圖瞭解在運行VBA我繼續實現其全部潛力。我真的很感激你指出我犯的那個昏暗的錯誤! –
克里斯,我得到一個運行時錯誤「數組下限必須爲零」任何想法爲什麼發生這種情況/靈魂? –
錯誤是哪一行?如果它的'mailid'''mailid''昏暗'怎麼樣? –