A
Ashley
I created a command button on my custom form and when its clicked I want the following code to run. here is my code, but nothing happens when I click on the button. I know my code works when I run it mannually.
Thanks
Sub CommandButton1_Click()
Dim item As MailItem
' Set item = Outlook.Application.ActiveExplorer.Selection.item(1)
Set item = Outlook.Application.ActiveInspector.CurrentItem
Dim olApp As Outlook.Application
Dim olTsk As TaskItem
Dim userField As Outlook.UserProperty
Set olApp = New Outlook.Application
Set olTsk = olApp.CreateItem(olTaskItem)
With olTsk
> Subject = item.Subject
> Status = olTaskNotStarted
> Body = item.Body
Set ups = item.UserProperties
Set prp = ups.Find("DateDue")
> DueDate = ups("DateDue").Value
> Save
End With
Set olTsk = Nothing
Set olApp = Nothing
End Sub.
Thanks
Sub CommandButton1_Click()
Dim item As MailItem
' Set item = Outlook.Application.ActiveExplorer.Selection.item(1)
Set item = Outlook.Application.ActiveInspector.CurrentItem
Dim olApp As Outlook.Application
Dim olTsk As TaskItem
Dim userField As Outlook.UserProperty
Set olApp = New Outlook.Application
Set olTsk = olApp.CreateItem(olTaskItem)
With olTsk
> Subject = item.Subject
> Status = olTaskNotStarted
> Body = item.Body
Set ups = item.UserProperties
Set prp = ups.Find("DateDue")
> DueDate = ups("DateDue").Value
> Save
End With
Set olTsk = Nothing
Set olApp = Nothing
End Sub.