atw: Re: Word Control Toolbox toolbars ... (Was: Word Template Help)

  • From: Neil Maloney <maloneyn@xxxxxxxxxxx>
  • To: austechwriter@xxxxxxxxxxxxx
  • Date: Mon, 15 Aug 2011 19:48:07 +1000

Rhonda,

Sorry, no success with that code for the two documents mentioned in my post (I've kept a version copy of the client document which still displays the toolbars when opened).

I made a working copy of the client document and created a new test.doc, added the sub-routine to my Normal.dot macros, opened each document in turn, ran the code (the toolbars didn't disappear), edited the document so it could be saved, then saved and re-opened it. The toolbars were still there.

I tried it again, with just the 'test' document, this time I 'manually' closed the toolbars after running the code and before closing the document. Same result. So then, third time lucky, I closed the toolbars before running the code ... but no difference, they were still there when I re-opened the document.

I then went to an old client template that automates a suite of letters through a VBA data entry interface – what goes into the data entry form populates the letter but also decides which of about 46 different flavours of letter is produced (internal / external applicant; full time / part time / casual; applicable award; etc.). I turned on the two toolbars, edited the document so it could be saved, saved it and then re-opened it and ran the code. This time, the toolbars disappeared and stayed that way. However, the same thing happens if I manually close the toolbars and then save the document, but that's only because the toolbars were displaying because I selected them, as opposed to a VBA component having an "open designer associated with it".

So, the code probably does work correctly in cases where the toolbars are displaying for the reason stated (elements linked to the designer being open) but I guess falls over in other situations. The difference would be that where there are design elements that have an open designer associated with them, the code is most likely necessary to the correct working of the document and, therefore, deleting the VBA module would NOT be an option ...

... I then played around with the code a bit, creating a new user form in my test document and running the code while I had both the document and the VBA Editor open side-by-side. What the code does is, if a user form and any associated dialogs (e.g. Toolbox) are displaying in the VBA Editor code window, it changes the view so they are no longer visible. That's all it appears to do. I had the Toolbox controls open at the time and when I double-clicked on the Form module name to display the (blank) form again, the Toolbox controls were still open. The code doesn't appear to do anything at all in any of the other views (macro code, user form code). If that's all that the code does, then it would be simpler just to jump into the Editor and change the view so that the user form isn't displaying.

Neil.


I then went to an old template I have that automates a suite of letters through a VBA data entry interface, i.e. which includes Forms, and which (I remembered) has the toolbars displaying

On 15/08/2011 6:38 PM, Rhonda Bracey wrote:
Neat tip, Neil!
 
Did you try this macro too? http://word.tips.net/T001596_Suppressing_the_Control_Toolbox_Toolbar.html (I wrote about this macro in a blog post back in 2008 [http://cybertext.wordpress.com/2008/10/29/word-2003-controlbox-toolbar-wont-go-away/] but have never tried it -- I like your solution better as it's quicker, easier, and easier to remember!)
 
Rhonda

Rhonda Bracey
rhonda.bracey@xxxxxxxxxxxxxxxx
http://www.cybertext.com.au
CyberText Newsletter/blog: http://cybertext.wordpress.com
Author-it Certified Consultant

 


From: austechwriter-bounce@xxxxxxxxxxxxx [mailto:austechwriter-bounce@xxxxxxxxxxxxx] On Behalf Of Neil Maloney
Sent: Monday, 15 August 2011 3:14 PM
To: austechwriter@xxxxxxxxxxxxx
Subject: atw: Word Control Toolbox toolbars ... (Was: Word Template Help)

Back in May, there was a Word Template Help thread started by Ken Fredric, who had the Microsoft Word and VBA Control Toolbox / Design Mode toolbars displaying in a document and they wouldn't go away. Very annoying, it has happened to me in the past and, from the thread, to others as well.

While Ken was able to solve his problem, I have just had this happen with one of my documents, and have more information about why it happens, which may be useful to others when and if it occurs.

Some knowledge of the VBA Editor is needed for the following to make sense, but if you ever need to get rid of these toolbars and aren't familiar with the Editor (including how to get into it), send me a mail or post to the list.

Attempting to turn off the toolbars, including using macro code to do this, accomplished nothing. I then thought of looking at the VBA structure of the document, and found that a "NewMacros" module was included as part of the document structure – don't ask me how I managed to do that, I have no idea. ("NewMacros" is the default VBA Editor name for a new code module.)

So the tree diagram for the document (not the underlying template) in the Project Explorer window was:

Project [Document Name]
– Microsoft Word Objects
   ... This Document
– Modules
   ... NewMacros
– References
   ... Reference to [Underlying Document Template Name]

Deleting the "NewMacros" module stopped the Control Toolbox / Design Mode toolbars displaying each time the document opened.

I then created a test document, added a "New Macro" module to the document's VBA structure, and Bingo, the toolbars displayed when I saved, closed then re-opened the document. There's no difference whether the module has code in it or not. Deleting the module from the test document stopped the toolbars displaying.

So it appears that the solution to these toolbars appearing is to delete the New Macros module, simple as that, one easy step.

Cheers,
Neil.

************************************************** To view the austechwriter archives, go to www.freelists.org/archives/austechwriter To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with "unsubscribe" in the Subject field (without quotes). To manage your subscription (e.g., set and unset DIGEST and VACATION modes) go to www.freelists.org/list/austechwriter To contact the list administrator, send a message to austechwriter-admins@xxxxxxxxxxxxx **************************************************
************************************************** To view the austechwriter archives, go to www.freelists.org/archives/austechwriter To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with "unsubscribe" in the Subject field (without quotes). To manage your subscription (e.g., set and unset DIGEST and VACATION modes) go to www.freelists.org/list/austechwriter To contact the list administrator, send a message to austechwriter-admins@xxxxxxxxxxxxx **************************************************

Other related posts: