<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Custom Ribbon: The macro cannot be found or has been disabled because of your security settings

Published on
11,901 Points
5,901 Views
Last Modified:
Approved
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
0
Comment
Author:Hitchhikers
  • 2
2 Comments
LVL 15

Expert Comment

by:DrTribos
Hello Hitchhikers,

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."

Details:
Unspecified error
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  :-(
0
LVL 15

Expert Comment

by:DrTribos
After much toil - the problem was caused by a rich text content control somehow being absorbed by a nearby picture content control.  Deleting the rich text content control fixed the document.

Hope this helps someone out there :-)
0

Featured Post

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Join & Write a Comment

Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Basic Overview of office 365 user portal

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month