K
Kathy Drungilas
I have a task form with a user-defined field ("Implementer") on a new
page(Environmental Info). The field contains text of a user's name. I want
to select tasks where this field is not blank, then send the task to the
name of the person in the field. [Forgive my VBA skills, as a beginner I
still feel like I'm learning a foreign language.]
I receive an run-time error, "91" Object variable or With block not set" on
my Set taskSafeRecip = _ plantTask.UserProperties("Implementer") line. Am I
referencing my custom field correctly? or doing something else wrong?
Sub AssignEnvironmentalPlantTasks()
Dim objApp As Outlook.Application
Dim objNS As NameSpace
Dim objMe As SafeCurrentUser 'Redemption object
Dim plantTasks As MAPIFolder
Dim plantTask As TaskItem
Dim taskSafeRecip As Redemption.SafeRecipient
'Dim strResponsible As String
'reference the mailbox folder to work with
Set objNS = Application.GetNamespace("MAPI")
Set plantTasks = objNS.GetDefaultFolder(olFolderTasks)
Set taskSafeRecip = plantTask.UserProperties("Implementer")
'Loop through all Tasks in Tasks Folder
For Each plantTask In plantTasks.Items
If plantTask.DelegationState = olTaskNotDelegated Then
plantTask.Assign
' Set tskResponsible = plantTask.Recipients.Add("strResponsible")
Set tskResponsible = plantTask.Recipients.Add("taskSafeRecip")
MsgBox "Assigning Plant Tasks, please wait"
'safely resolve recipient addresses
taskSafeRecip.Resolve
plantTask.Send
End If
Next
Set plantTask = Nothing
Set plantTasks = Nothing
Set objNS = Nothing
End Sub
Kathy Drungilas--
to answer via email, remove [nospam] from address
page(Environmental Info). The field contains text of a user's name. I want
to select tasks where this field is not blank, then send the task to the
name of the person in the field. [Forgive my VBA skills, as a beginner I
still feel like I'm learning a foreign language.]
I receive an run-time error, "91" Object variable or With block not set" on
my Set taskSafeRecip = _ plantTask.UserProperties("Implementer") line. Am I
referencing my custom field correctly? or doing something else wrong?
Sub AssignEnvironmentalPlantTasks()
Dim objApp As Outlook.Application
Dim objNS As NameSpace
Dim objMe As SafeCurrentUser 'Redemption object
Dim plantTasks As MAPIFolder
Dim plantTask As TaskItem
Dim taskSafeRecip As Redemption.SafeRecipient
'Dim strResponsible As String
'reference the mailbox folder to work with
Set objNS = Application.GetNamespace("MAPI")
Set plantTasks = objNS.GetDefaultFolder(olFolderTasks)
Set taskSafeRecip = plantTask.UserProperties("Implementer")
'Loop through all Tasks in Tasks Folder
For Each plantTask In plantTasks.Items
If plantTask.DelegationState = olTaskNotDelegated Then
plantTask.Assign
' Set tskResponsible = plantTask.Recipients.Add("strResponsible")
Set tskResponsible = plantTask.Recipients.Add("taskSafeRecip")
MsgBox "Assigning Plant Tasks, please wait"
'safely resolve recipient addresses
taskSafeRecip.Resolve
plantTask.Send
End If
Next
Set plantTask = Nothing
Set plantTasks = Nothing
Set objNS = Nothing
End Sub
Kathy Drungilas--
to answer via email, remove [nospam] from address