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.
Application.CommandBars("Standard").Visible = False
Repeat this for all the bars you want to hide.
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
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.
Try this one, will do all toolbars at once:
'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.)
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".
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.
thanks much
Private stuff did not work...but got the gist of it...alot of help
Huh? Private didn't work? Weird. Did you replace "Private" with "Dim"?
np...it did not like it below previous sub in module...moved it up...worked fine
Your help is much appreciated!!! :)