Solved

Office Toolbars

Posted on 2002-05-27
11
442 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 50 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

733 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