![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
I have a macro with the following line:
Dim olApp As Object, olMail As Object Dim rngeAddresses As Range, rngeCell As Range Set olApp = CreateObject("Outlook.Application") Set rngeAddresses = Application.InputBox(prompt:="Give a text" For Each rngeCell In rngeAddresses.Cells Set olMail = olApp.CreateItem(olMailItem) olMail.To = rngeCell.Value I can use the O.K. button,but by press the CANCEL-button,I receive an errormessage on the line : Set rngeAddresses..... Can somebody give me a solution ? Many thanks. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Try;
Dim olApp As Object, olMail As Object Dim rngeAddresses As Range, rngeCell As Range Set olApp = CreateObject("Outlook.Application") On Error Resume Next Set rngeAddresses = Application.InputBox(prompt:="Give a text", Type:=8) If Err Then Exit Sub On Error GoTo 0 For Each rngeCell In rngeAddresses.Cells Set olMail = olApp.CreateItem(olMailItem) olMail.To = rngeCell.Value Next |
|
|
|
|
|
#3 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
Quote:
Still a little question. In this macro I must filled in a range: exeample : A5 : A20 Is it possible that this macro can filled in automatickly the range. The range is from A5 to the last row of column A.So I must not each time filled in manualy the range and I still have the possibility to change the range. Thank for your time. |
|
|
|
|
|
|
#4 | ||
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Dim olApp As Object, olMail As Object Dim rngeAddresses As Range, rngeCell As Range Set olApp = CreateObject("Outlook.Application") On Error Resume Next Set rngeAddresses = Range(Range("A5"), Range("A5").End(xlDown)) If Err Then Exit Sub On Error GoTo 0 For Each rngeCell In rngeAddresses Set olMail = olApp.CreateItem(olMailItem) olMail.To = rngeCell.Value Next |
||
|
|
|
|
|
#5 | |||
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
Quote:
Thanks for your time. |
|||
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|