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
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
I am having a similar problem with my ribbon. In my scenario I have my ribbon calling macros in a dedicated module already (modRibbon) from there other macros are fired.
Occasionally something happens and I loose my ribbon. The error is the same as what you posted: "The macro cannot be found or has been disabled because of your security settings".
I can run my macros from within the VB Editor, the ribbon is there but it is empty (my ribbon images are loaded via VBA and not included with the XML in the document template).
This has happened to me twice now. Both times the fix was different (and stumbled upon, so I can't really elaborate). Fix 1 involved deleting all macros via the organizer and replacing them with a backup copy. Fix 2 involved commenting out some code in "This Document" and saving and restarting word. The code that I commented out was simply to set the saved state of the template to saved when a document was closed, so nothing fancy.
So at least my template is fixed.
Unfortunately, now for the 2nd time, my document is corrupted somehow. The 2nd corruption coincided with my ribbon failing. I am not sure about the first. Both times I was editing VBA whilst working on the document... probably not such a good idea.
When I try to open the document it I get:
"The file DOCUMENT.docx cannot be opened because there are problems with the contents."
Location: Part: /word/document.xml, Line: 2, Column: 0
This specific Unspecified Error seems fairly common. I'm not sure if the two are related. The repair feature in MS word does not work. I don't have a fix :-(
Hope this helps someone out there :-)