Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Menus and Toolbars / November 2005

Tip: Looking for answers? Try searching our database.

How to hide all menus and toolbars

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gina - 03 Nov 2005 11:02 GMT
Hi all.

I have a template that gets called from within vba....

In this template I would like to hide all menus and commandbars and
particularly features like 'save' and 'save as' from the user.

The template should only be usable when called from my application ( it gets
renamed to a *.dot before usage and destroyed afterwards)

In order to make the commandbars invisible I recorded a macro ....
CommandBars("Standard").Visible = False
....
so far so good ( is there a better way to do this ? -> something like : hide
any toolbar and then show only my own )

in fact I would like to
1.    hide all commandbars apart from my own, that lets the user print 1 or
2 copies and then closes the doc without saving
2.    do not provide any menu either
3.    disable the possibility to right-click the toolbar in order to select
any toolbar

hope I can get across what I intend to do ?!? hope it makes sense

Many thanks in advance

Gina
Charles Kenyon - 03 Nov 2005 17:08 GMT
You would want to go through the entire commandbars collection and mark them
all invisible and disabled and then fix it when you left. Have you thought
about the situation where the user already has Word open and is working on
another document while your application is running? How about the user
double-clicking on another Word document from Windows while yours is
running? If the computer crashes while your application is running, do you
want it to disable Word for other use? If this happened to me because I was
using your application, I would consider a lawsuit. I would certainly be
unhappy and vocal in my unhappiness.

How about the situation where the user presses Ctrl-S or clicks on the close
button and is prompted about saving changes?

What, exactly, are you trying to accomplish by doing this? Because it will
be hard to do and ultimately will not be secure even if you cover all the
bases. If a person can read a document, they can copy it, if necessary by
writing out the contents in longhand and retyping.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Hi all.
>
[quoted text clipped - 28 lines]
>
> Gina
Gina - 04 Nov 2005 08:54 GMT
Charles,

many thanks for answering so extensively.... I tested the situations you
described and indeed Normal.dot is affected by all the hiding stuff :-((

a fact I haven't thought of yet .... big problem now...
I am not familiar with word coding or behaviour ... my thoughts were: when I
do a macro to hide/ disable all but my personal toolbar it would only affect
documents coming from that particular template ..... Invoice1.dot

here's my code
***
Sub HideAllToolbars()

Dim i As Integer
i = 1

   Application.WindowState = wdWindowStateNormal

   If ActiveDocument.AttachedTemplate = "Invoice1.dot" Then

       Do

           If ActiveDocument.CommandBars(i).Name <> "Invoice" Then
               ActiveDocument.CommandBars(i).Enabled = True
           Else
               ActiveDocument.CommandBars(i).Enabled = False
           End If

           i = i + 1
       Loop While i < (ActiveDocument.CommandBars.Count)

       CommandBars("Invoice").Enabled = True
       CommandBars.AdaptiveMenus = False

 End If
End Sub
***
Sub AutoExec()
   HideAllToolbars
End Sub
***

What I am trying to accomplish:
my 'invoicing programme' in access 2000 is transferring data to word.
Before, the company was writing their invoicing stuff still on a typing
machine.  I would like to make sure, that if they want to use a computer for
the invoicing, they should do it through my programme and ultimately renew
the license after a year rather than making a copy of my template by typing
invoices in word itself!!

therefore I do not work on a 'visible' *.dot .... and via access vba a copy
is made and named appropriately and destoys the copy afterwards.

You are definitrely right ..... I would be very angry if any programme would
affect my other work with word negatively in any way!!! I would sue them as
well!!

Maybe you have an idea of how I can code what I intend to do ....
if at all...

Gina

> You would want to go through the entire commandbars collection and mark them
> all invisible and disabled and then fix it when you left. Have you thought
[quoted text clipped - 45 lines]
> >
> > Gina
Gina - 04 Nov 2005 15:58 GMT
Charles,
made some changes to the code:
basically the main thing I would want is the right-click on the remaining
toolbar 'Invoice' - the customization !!!
... where they can get what they want
there is no'right-click' anymore nowhere in the doc created from
Invoice1.dot .... but still with the remaining toolbar .... oh dear

I changed my code so normal.dot and any doc created from it and from any
other *.dot apart from the Invoice1.dot aren't anymore affected ....so far
so good but all the stopping macro keys on opening have not been dealt with
....

neither the fact that when user changes something in the document the dialog
save with the 3 upcoming options, they get promted :-(

Gina

***
Sub HideAllToolbars()
Dim i As Integer
i = 1

   Application.WindowState = wdWindowStateNormal

   If ActiveDocument.AttachedTemplate = "Invoice1.dot" Then
       If ActiveWindow.Active = True Then

           Do
               If Not (ActiveDocument.CommandBars(i).Name = "Invoice") Then
                   ActiveDocument.CommandBars(i).Enabled = False
               Else
                   ActiveDocument.CommandBars(i).Enabled = True
               End If
               i = i + 1
           Loop While i <= (ActiveDocument.CommandBars.Count)
       End If
       CommandBars.AdaptiveMenus = False
   Else
       Do
           ActiveDocument.CommandBars(i).Enabled = True
           i = i + 1
       Loop While i <= (ActiveDocument.CommandBars.Count )
       CommandBars.AdaptiveMenus = True

   End If

   CommandBars("Invoice").Enabled = True
   CommandBars("Invoice").Visible = True

End Sub
***
Sub AutoNew()
   HideAllToolbars
End Sub
***
Sub AutoExit()
   HideAllToolbars
End Sub
***

> Charles,
>
[quoted text clipped - 112 lines]
> > >
> > > Gina
Tony Jollans - 04 Nov 2005 19:24 GMT
Hi Gina,

You should be able to disable the toolbar right click by ..

CommandBars("Toolbar List").Enabled = False

but that doesn't entirely stop user customization.

--
Enjoy,
Tony

> Charles,
> made some changes to the code:
[quoted text clipped - 202 lines]
> > > >
> > > > Gina
Charles Kenyon - 04 Nov 2005 16:20 GMT
You can set the customization context to your template.
CustomizationContext = ActiveDocument.AttachedTemplate

You don't want ActiveDocument.CommandBars but Application.Commandbars or
simply CommandBars, I think.

I would recommend posting your working code in the vba.customization
newsgroup. I am really a beginner at this.

Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Charles,
>
[quoted text clipped - 123 lines]
>> >
>> > Gina
Charles Kenyon - 04 Nov 2005 16:42 GMT
Also, take a look at the MVP FAQs on customization and vba. One page that
may help is http://word.mvps.org/FAQs/MacrosVBA/SetPosnOfCmdBars.htm. You
can position commandbars off the screen!

Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> You can set the customization context to your template.
> CustomizationContext = ActiveDocument.AttachedTemplate
[quoted text clipped - 137 lines]
>>> >
>>> > Gina
Gina - 07 Nov 2005 16:18 GMT
Hi Charles and Tony

Sorry I have been a few days off.

Tony's 'CommandBars("Toolbar List").Enabled = False'
did the desired trick :-))

Charles, I will follow your advice with changing to the vba cust newsgroup
... thanks for the link!!!

Many many thanks for your help with my problem(s) !!

Gina

> Also, take a look at the MVP FAQs on customization and vba. One page that
> may help is http://word.mvps.org/FAQs/MacrosVBA/SetPosnOfCmdBars.htm. You
[quoted text clipped - 142 lines]
> >>> >
> >>> > Gina
Tony Jollans - 07 Nov 2005 17:11 GMT
Glad that did the trick for you.

> Sorry I have been a few days off.

You're allowed - it _was_ the weekend :)

--
Enjoy,
Tony

> Hi Charles and Tony
>
[quoted text clipped - 207 lines]
> > >>> >
> > >>> > Gina
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.