Outlook Script Have Pb with Do While Loop

B

bbnimda

Hi all

I'm using a custom Outlook form

I this form I use Do while loop, it work fine but Now I need to skip some
item that meet specific conditions so I added an if then loop end if

My working Script
===============================
Do While not (MyItem is Nothing)
Action1
Action2
Action3
loop
===============================

In my New Script I want to skip all Item that have companies name
"COMPNAME"
when I add an other loop inside the "if then" my form don't work and return
message that "do" is missing

===============================
Do While not (MyItem is Nothing)
Action1
Action2
Action3
if MyItem.companies = "COMPNAME" then
loop
end if
loop
===============================

thks for Help
 
S

Sue Mosher [MVP-Outlook]

If you want another loop to run inside the If ... End If block, then that
needs to begin with a Do statement, just like the outer look.

If you want to perform actions only on items meeting certain criteria, then
put those actions inside an If ... ENd If block, for example:

Do While not (MyItem is Nothing)
if Not MyItem.companies = "COMPNAME" then
Action1
Action2
Action3
end if
loop
 
B

bbnimda

Hello Sue

I don't Want to perform another loop

I just want to skip item inside my "Do loop" and I can't use in fact all
my item meet more than 4 criteria and in this list I want to skip some
Item that meet 2 Criteria

after each loop I Add to a list the item and I tagg it with a specific color
to an Excel file and after each loop I go to the next line on Excel if I
ignore an item I'll
have blank line between writen lines


here a part of my code
============================
set myitem = items.find(..........)
Do while
if condition1 then
Itemcolor = 1
if condition2 then
Tagg = A
else
Tagg = B
end if
else
if THECONDITON then
HERE WHERE I WANT TO SKIP
I don't want continue with this Item and bo back to the begining
of my loop and proceed with the next item
end if
end

action1
action2
action3

Actionx = add information about the item to Excel by putting in each cell
item infomation by scrolling column
ActionZ = go to the next line in Excel
loop


I Hope I'm clear... ;)

============================
 
S

Sue Mosher [MVP-Outlook]

Sorry, but I can't follow your logic. It's not at all clear whether your
conditions are mutually exclusive or overlapping or what if anything Tagg and
ItemColor have to to with THECONDITION. The basic logic you need to follow is
as I gave in my previous response: Test for criteria and perform actions only
on those items meeting the criteria. (The details of the actions don't matter
at this point, BTW.) That's how you skip items in a loop that don't meet
those criteria.

Maybe instead of generalities, you could give us some specifics to work with.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 

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