There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer bios black screen blue screen boot computer connection crash css dell display driver drivers email error excel firefox firefox 3 hard drive internet internet explorer itunes laptop lcd malware monitor network networking nvidia outlook outlook 2003 outlook express password printer problem problems router security slow software sound startup trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Solved: VBA in Microsoft Word


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
drawde's Avatar
Junior Member with 18 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate/Advanced
17-Aug-2006, 05:39 AM #1
Solved: VBA in Microsoft Word
Hi

I am trying to write some macros in Word, and teaching myself VBA as I go.

Is it possible to use some kind of "or" function with an IF statement?

I want to display a userform if toolbar1 or toolbar2 is visible, but display a different userform if neither toolbar is visible. I can do this if only one toolbar is used:

If CommandBars("Toolbar1").Visible = False Then
Userform1.Show
Else
Userform2.Show
End If

But I need it to run if either toolbar1 or toolbar 2 is visible. Is there some kind of "or" command that I can use? I tried using two separate If statements:

If CommandBars("Toolbar1").Visible = False Then
Userform1.Show
Else
Userform2.Show
End If
If CommandBars("Toolbar2").Visible = False Then
Userform1.Show
Else
Userform2.Show
End If

But this displays both userforms!

Any help would be much appreciated!

drawde
Jimmy the Hand's Avatar
Senior Member with 794 posts.
 
Join Date: Jul 2006
Location: Hungary
Experience: With Excel, fairly good.
17-Aug-2006, 09:27 AM #2
Try this

Code:
If (CommandBars("Toolbar1").Visible = True) or (CommandBars("Toolbar2").Visible = True) Then
     Userform2.Show
Else
     Userform1.Show
End If
which is equivalent with

Code:
If CommandBars("Toolbar1").Visible or CommandBars("Toolbar2").Visible Then
     Userform2.Show
Else
     Userform1.Show
End If
drawde's Avatar
Junior Member with 18 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate/Advanced
18-Aug-2006, 05:01 AM #3
I never thought to put the "or" there!

Works perfectly, thanks very much!
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:28 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.