Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Office Toolbars

Posted on 2002-05-27
11
Medium Priority
?
445 Views
Last Modified: 2006-11-17
Hello.

When I open an office document I want some toolbars to be disabled (this is for a template that I am trying to make). I use the following vba code but it does not even run. Can anyone help me?


--------------------------------------------------

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)

Dim cbars As CommandBars
Dim cbar1 As CommandBar
Dim cbar2 As CommandBar

Set cbars = Application.CommandBars


Set cbar1 = cbars("Standard")
Set cbar2 = cbars("Formatting")

'Disable the command bars

cbar1.Enabled = False

cbar2.Enabled = False

End Sub
0
Comment
Question by:kkarnez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
11 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 7037176
Hi Kkarnez,

how are you calling this function?

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)

End Sub

you've to call it in the open event of the thisdocument object

Private Sub Document_Open()
  call Sub Document_DocumentOpened(ActiveDocument)
End Sub

you could even do it like

Private Sub Document_Open()
Dim cbars As CommandBars
Dim cbar1 As CommandBar
Dim cbar2 As CommandBar

Set cbars = Application.CommandBars


Set cbar1 = cbars("Standard")
Set cbar2 = cbars("Formatting")

'Disable the command bars

cbar1.Enabled = False

cbar2.Enabled = False
End Sub


if you need any more help just leave the comments here and we're try to make it work

HTH:O)Bruintje
0
 

Author Comment

by:kkarnez
ID: 7037194
Hi.

It didn't work. I've put it under ThisDocument (general section).
Where should I put it?

-------------------

Private Sub Document_Open()

Dim cbars As CommandBars
Dim cbar1 As CommandBar
Dim cbar2 As CommandBar

Set cbars = Application.CommandBars


Set cbar1 = cbars("Standard")
Set cbar2 = cbars("Formatting")

'Disable the command bars

cbar1.Enabled = False

cbar2.Enabled = False
End Sub
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7037759
Hi Kkarnez,

you can download a sample document with this code in the open event

if you open it will first show a message box and then hide the bars

if it works then you can play a bit more with it, we;ve to make sure that cod eis running anyway

it could also be the settings in your word where no macros is checked check tools | macro | security it should be able to run at least macros

http://www.bredlum.com/ee_temp/commandbar.doc

HTH:O)Bruintje
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:macbone2
ID: 7037895
Hi bruintje, being curious and a trusting idiot I clicked on your link. It disabled the command bars in Word, but also removed them from View | Toolbars. I got them back by running the macro with enabled = true. However, the appearance of my web browser has also been changed and I can't get back to how it was. Any suggestions?

macbone2
0
 
LVL 2

Expert Comment

by:macbone2
ID: 7037902
What I mean is I've got some of the toolbar icons, but they are all overlaid on top of each other at the top of the screen, and I can't drag them down. Help!!
0
 
LVL 2

Expert Comment

by:macbone2
ID: 7037904
Forget that. I've sorted it by toggling full screen off.
Sorry to waste your time.

ta  macbone2
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7038354
macbone2 > you're right about getting them back with enabled = true you can always add that on the document_close event so things will be restored on closing the template

glad i was sleeping through it because i wouldn't know why it had an effect on the browser :)
0
 

Author Comment

by:kkarnez
ID: 7038651
Hi.

Actually I dont use word but visio 2000.
The default function that does the same work like
Document_Open is :

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)

There is no Document_Open !!.

Anyway, I've checked the sequrity and it is in medium which should cause no problem. Your example works fine by the way...
0
 
LVL 44

Accepted Solution

by:
bruintje earned 200 total points
ID: 7038663
hmm....forgot to ask what app you used visio is at home so i can make some intelligent comment later on, or hopefully someone with visio at hand will log on

:O)Bruintje
0
 

Author Comment

by:kkarnez
ID: 7038766
I found it!!

it just doesnt work if the file is a visio template and not a simple document... WHY???

Microsoft sucks!!

thanks for your help
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7038786
thanks and that's a good question i'll try to find that out later :)
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question