Toolbars

F

Francis Hookham

With much help from the microsoft.public.excel.programming group I can now
have a workbook with its own toolbars which will open and close on another
computer where the workbook is being used. In the same way can a Word
document or template, other than Normal include its own Module:



Option Explicit

Sub create_menubar()

....

....

End Sub



to run macros included in that document, rather than in Normal.



Although I have plenty of experience of VBA in XL, both in Personal.xls and
in Workbooks, my only experience in Word is within Normal.



Has anyone experience of this?



Francis Hookham
 
J

Jay Freedman

If the macros are stored in the specific template, you can also create and
store the custom toolbar in the same template (in the Tools > Customize
dialog, click the Toolbars tab, click the New button, and make sure the
"Make toolbar available to" box is set to the name of the correct template).
Then use the Commands tab of the same dialog, with "Macros" selected in the
Categories list, to choose your macros and drag them to your toolbar.
Finally, right-click the button on the toolbar and change the name, icon,
and display mode of the button.

There's no need to construct the toolbar in code, and in fact there's a good
reason not to: In Word, creating a toolbar in code dirties the document,
even if the user doesn't do any work and immediately closes the document.
Then you need code to set the document's .Saved property to True (tell Word
that the document isn't really dirty)... it's a big mess. Avoid it.

Store the macros and the toolbar in a template, not in a document. (This is
different from Excel, where you store macros in a workbook.) Word considers
any kind of active content in a document to be a potential virus, and then
you have to get into code signing and security measures. Avoid that, too.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
F

Francis Hookham

Very clear and helpful - I can see it will be much easier than in XL.

Thank you,

Francis Hookham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top