Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Toolbar button from MSWord

Status
Not open for further replies.

JPJeffery

Technical User
May 26, 2006
600
0
0
GB
(I'll be posting this in the MS Office Suite forum as that makes more sense but as there's some commonality between vbscript and VBA I thought I'd post here too...)

I need to delete a toolbar button from MANY PCs in our organisation.

I'm already due to visit each PC to run a script to gather information about each PC so my idea was to create a .DOT file with an Auto.main containing the code to delete the button if it exists.

I've found the .DOT file that created the button and it contains the following lines:

Code:
Rem --- Reset the standard toolbar and add in a single button
WordBasic.ViewToolbars Toolbar:="Standard", Context:=0, Reset:=1
WordBasic.AddButton "Standard", 1, 2, "CORP", "CORP", 0
WordBasic.AddButton "Standard", 2, 1, "", "", 0

However, I can't find any info on WordBasic.RemoveButton (or is it DeleteButton?). Is this the right way to go about this task? The user's currently have Office 2000 which makes me think the code would be VBA rather than WordBasic (which, CMIIW, was dumped in favour of VBA)...

JJ
 
Hi JP

You want to post this in the VBA forum, and forget about wordbasic - that was superceeded by vba. Wordbasic still works (sort of) but VBA is so much easier.

A quick note about your module name - your Module wants to be called AutoExec, Not Auto, and the sub called Main eg Sub Main().

Once you have done that you need to track down the button you want to hide. If it is a Microsoft button you can track it down by its ID number (eg see below)

Dim myButton as CommandBarButton
Set myButton = CommandBars.FindControl _(Type:=msoControlButton, ID:=2520) 'New Blank Document
If myButton.Visible = True Then
myButton.Visible = false
End If

If it is on a custom toolbar you could also track it down by its position (index) or name if you know it(eg see below)

Application.CommandBars("My Toolbar Name").Controls (index).visible=false

Application.CommandBars("My Toolbar Name").Controls ("My Button Name").visible=false


Just a starter. Hope it helps

Adam Jeffery (- any relation?)
 
Sorry, that should say:
Set myButton = CommandBars.FindControl (Type:=msoControlButton, ID:=2520) 'New Blank Document
 
Adam! How are you? Haven't heard from your side of the family...um, at all, come to think of it. :)

Anyway, yes I didn't even bother with WordBasic and got it working with VBA. However, as with all these tasks, the requirements have been added to, which has produced a new problem. See my new thread in the VBA forum (and duplicated in the MSOffice forum)...

Thanks.

JJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top