Problem with OR operator

B

Bert

I have a macro that is to open only Word or Excel
documents. Anything else bypasses the code. If I test for
Word documents with :

If strExtension <> ".doc" Then GoTo NextLink

then the Word docs are processed, eveything else bypasses.
If I test for Word and Excel docs with:

If strExtension <> ".doc" Or strExtension <> ".xlw" Then
GoTo NextLink

everything bypasses the code. Why?
 
H

Helmut Weber

Hi Bert,
it is a matter of logic.
If strExtension <> ".doc" Or strExtension <> ".xlw" Then
GoTo NextLink
try
strExtension <> ".doc" and strExtension <> ".xlw"
---
If you use "or" any string would be unequal to
one (1!) of the two Extensions.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

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