1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VB help creating a toggle button

Discussion in 'Business Applications' started by pickwick, Nov 4, 2007.

Thread Status:
Not open for further replies.
  1. pickwick

    pickwick Thread Starter

    Joined:
    Oct 31, 2007
    Messages:
    7
    I'm just starting to get my head around some basic VB programming for writing macros in word... and I need help already! Can anyone tell me how best to create a toggle button macro? I want to be able to show/hide a toolbar that I've created called 'Tables'.

    so far all I can work out is to open and then close the toolbar
    CommandBars ("Tables").Visible = True
    CommandBars ("Tables").Visible = False
    but I want to be able to do it with a single button, not two.

    I know it's basic, but ya gotta start somewhere!
     
  2. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Hi there, welcome to the board!

    Just check it's state. You can check the visible property as well as set it. You can also toggle it to the opposite state as it is a boolean (true/false) setting. Take a look at the following. ;) ...

    Code:
    commandbars("Tables").visible = not commandbars("Visible").visible
    HTH
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/647841

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice