Outlook Scipt: Search Pb

B

bbnimda

Hi all
I use Outlook Script and I've a syntax problem in searh instruction

in my form i Search contact item in other folder
==============================
myFolder = "here I go to the desired folder "
Set myItems = myFolder.Items

Target = "Here is the wanted CompanyName"

set myItem = Items.Find(["CompanyName]="""&Target&""" ")

If not (myItem Is Nothing) then

myitem.display

end if

=======================

I tryed diff syntax But I Always have an error
Tks for help
 
S

Sue Mosher [MVP-Outlook]

Two problems:

1) This statement instantiates an Outlook.Items object:

Set myItems = myFolder.Items

It is this myItems object whose find method you need to use in your find statement.

2) The statement also needs proper use of quotation marks and concatenation operators. I recommend building the search string in a separate statement so you can check it more easily:

strFind = "[CompanyName]=" & Chr(34) & Target & Chr(34)
MsgBox strFind
set myItem = myItems.Find(strFind)

If you continue to have problems, please provide information on the exact error(s) occurring.
 
B

bbnimda

Tks a lot Sue U were right the solution is to use chr(34) in stead of "

My search now work properly


Nb: Just for info, I all ready use Serch with quote "" and it still work
correctly why do I have now to use ascii code ??




"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le message
de [email protected]...
Two problems:

1) This statement instantiates an Outlook.Items object:

Set myItems = myFolder.Items

It is this myItems object whose find method you need to use in your find
statement.

2) The statement also needs proper use of quotation marks and concatenation
operators. I recommend building the search string in a separate statement so
you can check it more easily:

strFind = "[CompanyName]=" & Chr(34) & Target & Chr(34)
MsgBox strFind
set myItem = myItems.Find(strFind)

If you continue to have problems, please provide information on the exact
error(s) occurring.
 

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