Outlook Script: How to get the result of an action

N

news.microsoft.com

Hi all,

I want to check the result of an action to apply the de right function, In
my case I save a Task, I used a customized Form and I added a validation
control on some fields => the task can't be saved if some are empty

I want to know the result of this command

Item.Save

Tks
 
M

Michael Bauer [MVP - Outlook]

Am Wed, 18 Oct 2006 09:22:36 +0200 schrieb news.microsoft.com:

If the Save method fails it should raise an error.
 
N

news.microsoft.com

Yes I that if save fails it raise an error, but in my script how can I know
if the save was successfull or not

in my script I want to do this
Item.Save
If "the instruction was successfull " then <= I don't know how to do
this check
do some thing
else
do other thing
end if


Thks
 
M

Michael Bauer [MVP - Outlook]

Am Thu, 19 Oct 2006 10:15:25 +0200 schrieb news.microsoft.com:

For error handling in VB there are two opportunities:

1)
On Error Resume Next
Item.Save
If Err.Number <>0 Then ... ' no success

2)
On Error Goto ERR_HANDLER
Item.Save
' maybe more code here
Exit Sub
ERR_HANDLER:
' error handling here

#1 tells you exactly what line caused an error even if you don´t know the
error number. On the other side, if you do have more commands in the
function then it can really blow up the code.

#2 catches all errors even unexpected ones. You could add line numbers to
your code and the Erl function would tell you which line caused the error.
 
N

news.microsoft.com

It work great , Tks a lot

Bye
Michael Bauer said:
Am Thu, 19 Oct 2006 10:15:25 +0200 schrieb news.microsoft.com:

For error handling in VB there are two opportunities:

1)
On Error Resume Next
Item.Save
If Err.Number <>0 Then ... ' no success

2)
On Error Goto ERR_HANDLER
Item.Save
' maybe more code here
Exit Sub
ERR_HANDLER:
' error handling here

#1 tells you exactly what line caused an error even if you don´t know the
error number. On the other side, if you do have more commands in the
function then it can really blow up the code.

#2 catches all errors even unexpected ones. You could add line numbers to
your code and the Erl function would tell you which line caused the error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top