PDA

View Full Version : call item.display when using a form



johncassell
05-18-2015, 02:43 AM
Hi all, I am using this procedure which checks some things before the users email is sent.

Public Sub Application_ItemSend(ByVal item As Object, ByRef Cancel As Boolean)

It opens a form but I have a problem whereby when the form opens, the email I am composing is replaced by any one of the other emails that I am composing and it sends that other one instead. I have found a workaround in that if I specify 'item.display' when the form is closed, it brings up my correct email and then sends it perfectly.

My only problem now is that the user will be confused because when my form pops up because the wrong email is suddenly in the background - they will think its going to send that wrong email.

I'm looking in Private Sub UserForm_Activate() and was hoping to put 'item.display' somewhere in there so that as soon as the form is opened, the correct email is brought back into the background and my users are none-the-wiser.

However, I cant find a way of telling my userform what the 'item' is (I get Runtime error - Object Required).

Would anyone be able to tell me how to achieve this please. I am using Outlook 2003.

Thanks
John

johncassell
05-18-2015, 05:12 AM
Hi, managed to sort now (although still don't fully understand what the problem was). It appears that the Application_ItemSend procedure fires twice (Don't know why) and was causing problems with the form. I have now added the code 'Unload MyUserForm' at the beginning of this procedure so the form is removed from memory and starts afresh when the procedure fires each time. Everything working perfect now.