R
ryguy7272
The loop structure has always been difficult for me to grasp. Sigh...
I'm trying to figure out a way to loop through all used cells in Column C,
and run until a blank cell (probably "") is found, then stop. I would
probably start on C2, so I am thinking the looping portion of the code may be
something like this:
Dim i As Integer
i = 2
Do Until Cells(i, 3).Value = ""
....other code in here???
i = i + 1
Loop
The code that I have so far is below (and this works fine without the loop):
Sub GetOutlookReference()
'Outlook objects
Dim olApp As Outlook.Application
'Obtain a reference to Outlook
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
'*********************************************
Dim objApp As Object
Dim OutTask As Object
Set objApp = CreateObject("Outlook.Application")
Set OutTask = objApp.CreateItem(olTaskItem)
With OutTask
.StartDate = Range("C1")
.DueDate = Range("C2")
.Subject = Range("C3")
.Importance = olImportanceHigh
.Display
.ReminderSet = True
End With
'*********************************************
'If Outlook isn't running, start it and remember
If olApp Is Nothing Then
Set olApp = CreateObject("Outlook.Application")
End If
' If Outlook still isn't running, Outlook cannot open or is not installed
If olApp Is Nothing Then
Call MsgBox("Outlook could not be opened. Exiting macro.", _
vbCritical, Application.Name)
End If
End Sub
Finally, how can I get the values, which will be dates, to update as a Task
item in Outlook, and then get this to save automatically without the user
choosing to save the change (because all of these extra clicks would kind of
defeat the purpose of the loop, right)...
TIA,
Ryan---
I'm trying to figure out a way to loop through all used cells in Column C,
and run until a blank cell (probably "") is found, then stop. I would
probably start on C2, so I am thinking the looping portion of the code may be
something like this:
Dim i As Integer
i = 2
Do Until Cells(i, 3).Value = ""
....other code in here???
i = i + 1
Loop
The code that I have so far is below (and this works fine without the loop):
Sub GetOutlookReference()
'Outlook objects
Dim olApp As Outlook.Application
'Obtain a reference to Outlook
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
'*********************************************
Dim objApp As Object
Dim OutTask As Object
Set objApp = CreateObject("Outlook.Application")
Set OutTask = objApp.CreateItem(olTaskItem)
With OutTask
.StartDate = Range("C1")
.DueDate = Range("C2")
.Subject = Range("C3")
.Importance = olImportanceHigh
.Display
.ReminderSet = True
End With
'*********************************************
'If Outlook isn't running, start it and remember
If olApp Is Nothing Then
Set olApp = CreateObject("Outlook.Application")
End If
' If Outlook still isn't running, Outlook cannot open or is not installed
If olApp Is Nothing Then
Call MsgBox("Outlook could not be opened. Exiting macro.", _
vbCritical, Application.Name)
End If
End Sub
Finally, how can I get the values, which will be dates, to update as a Task
item in Outlook, and then get this to save automatically without the user
choosing to save the change (because all of these extra clicks would kind of
defeat the purpose of the loop, right)...
TIA,
Ryan---