Author Topic: Hide ALL toolbars code snippet  (Read 9165 times)

0 Members and 1 Guest are viewing this topic.

vojo

  • Hero Member
  • *****
  • Posts: 1674
Hide ALL toolbars code snippet
« on: August 25, 2008, 08:29:35 AM »
I want to turn on or off (make invisible or visible) all the toolbars in visio via a macro or some other.
Does anybody have a code snippet that does this.

The real problem trying to solve is that I would like to run in full screen mode but be able to click on shapes (fullscreen appears to be static "picture" of the diagram)...hence to get that view, want to turn off toolbars

Note if there is a switch to pull at visio invocation, that would even be better.

Lars-Erik

  • Sr. Member
  • ****
  • Posts: 278
Re: Hide ALL toolbars code snippet
« Reply #1 on: August 26, 2008, 01:07:31 AM »
Code
Application.CommandBars("Standard").Visible = False
Repeat this for all the bars you want to hide.

Code
Application.ActiveWindow.ShowRulers = False
Will hide your rulers.

To quickly find these commands, or to make a macro to do what you want try the following.

- Run the visio macro recorder
- Turn off all your bars
- Remove rulers, gridlines etc
- Any other stuff you want hidden
- Stop the macro recorder

Visio will have saved all the 'code' it ran when you removed stuff using your normal menu interface. Running the created macro will do everything you did while it was recording. So you just created a nice macro, and it required no coding skills at all.

- Lars

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1735
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Hide ALL toolbars code snippet
« Reply #2 on: August 26, 2008, 02:50:18 AM »
A few other notes:

Visio supports two UI models: Visio's built-in UI stuff, and the Office Command Bars. Visio's UI model is more flexible, and can apply to documents, instead of the whole application. Look in the developer help for Visio UIObject, and app.Menus, app.Toolbars, doc.Menus, doc.Toolbars.

You might want to save the existing UI in some way before you apply your "full screen mode". There's a way to export Visio UIs and re-import them. I'm not sure if command bars support this, though.

If you have other add-ins installed, keep in mind that they may have also edited the UI, and you might be stomping on their customizations. For this reason, it is good to work with the objects: CustomToolbars and CustomMenus. These also hang off of app or doc objects.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Lars-Erik

  • Sr. Member
  • ****
  • Posts: 278
Re: Hide ALL toolbars code snippet
« Reply #3 on: August 26, 2008, 06:00:58 AM »
Try this one, will do all toolbars at once:
Code
'toolbars
Application.ShowToolbar = False
'Other stuff
Application.ShowStatusBar = false
Application.ActiveWindow.ShowPageTabs = false
Application.ActiveWindow.ShowRulers = False

I dont think hiding the toolbars will upset anyplugins, they aren't removed, just hidden?

All you need it to close the windows the user has open... those are a little trickier.
There in the Application.ActiveWindow.Windows. (Don't know if theres an easy way to close them, and remember which were close so you can later set them back.)
« Last Edit: August 26, 2008, 06:11:41 AM by Lars-Erik »

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1735
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Hide ALL toolbars code snippet
« Reply #4 on: August 26, 2008, 10:13:11 AM »
Dude, nice one!

I totally missed the Application.ShowToolbar property. Much easier than messing with the UI objects...

I've written some code that saves the current view settings, then goes "full screen".

Code

Private m_toolBarVisible As Boolean
Private m_statusBarVisible As Boolean
Private m_pageTabsVisible As Boolean
Private m_rulersVisible As Boolean


Sub FakeFullScreenMode()

  '// Save the current settings:
  m_toolBarVisible = Visio.Application.ShowToolbar
  m_statusBarVisible = Visio.Application.ShowStatusBar
 
  m_pageTabsVisible = Visio.ActiveWindow.ShowPageTabs
  m_rulersVisible = Visio.ActiveWindow.ShowRulers
 
  '// Now go 'full screen' by turning everything off:
  Visio.Application.ShowToolbar = False
  Visio.Application.ShowStatusBar = False
  Visio.ActiveWindow.ShowPageTabs = False
  Visio.ActiveWindow.ShowRulers = False

End Sub

Sub Restore()

  Visio.Application.ShowToolbar = m_toolBarVisible
  Visio.Application.ShowStatusBar = m_statusBarVisible
  Visio.ActiveWindow.ShowPageTabs = m_pageTabsVisible
  Visio.ActiveWindow.ShowRulers = m_rulersVisible
 
End Sub

Sub RestoreAll()

  Visio.Application.ShowToolbar = True
  Visio.Application.ShowStatusBar = True
  Visio.ActiveWindow.ShowPageTabs = True
  Visio.ActiveWindow.ShowRulers = True
 
End Sub


So you paste this in a document's VBA project. You call FakeFullScreenMode to go into your full screen mode, then you call Restore to go back. If something goes wrong, call RestoreAll to get everything visible.

If the active window isn't a drawing window, you'll get an error. I didn't bother trapping this in the sample code.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

vojo

  • Hero Member
  • *****
  • Posts: 1674
Re: Hide ALL toolbars code snippet
« Reply #5 on: August 26, 2008, 01:04:18 PM »
thanks much

Private stuff did not work...but got the gist of it...alot of help

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1735
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Hide ALL toolbars code snippet
« Reply #6 on: August 26, 2008, 01:10:48 PM »
Huh? Private didn't work? Weird. Did you replace "Private" with "Dim"?
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

vojo

  • Hero Member
  • *****
  • Posts: 1674
Re: Hide ALL toolbars code snippet
« Reply #7 on: August 26, 2008, 01:16:58 PM »
np...it did not like it below previous sub in module...moved it up...worked fine
Your help is much appreciated!!! :)