I had the need of some functions in several MS Office (Word and Excel) documents, that just make sense in context of each single document and should not be visible while working with other files.
Because several users at different locations and on individual installed systems should be able to work with theese functions in the document or copies of it, I decided to customize the Ribbon for each single document or workbook, and not to customize my normal-template and also not to write an add in, that I would have to distribute separately to every possible user of the documents and workbooks.
Some time ago, I already used Custom UI Editor for customizing the ribbon in a Word template, so I looked for a short manual for using Custom UI Editor, the macro functions I already had written and ready.
There are a lot of instructions
available in the net, how to generate a custom Ribbon for Word 2010 or Excel 2010 with Custom UI Editor, and how the macros to be started by the Buttons in the Ribbon should look like.
Although following these instructions, I got an Error message "The macro cannot be found or has been disabled because of your security settings" when opening my Word or Excel Documents with the customized Ribbon. In Visual Basic Editor I saw the marcos, the security settings allowed them, but it did not work... So I looked for a solution, and found it while comparing a working document with my new one.
Reason / Solution:
The macros to be started by the Ribbon need to be in a "Macro Module", and never in the "Document" or "Workbook" / "Worksheet" context. To do so, open Visual Basic Editor, right-click on your project or document in the project browser, in the context menu choose insert -> module