Microsoft office documents customization

Cheok 0 Reputation points
2025-06-16T02:20:11.6333333+00:00

************** Exception Text **************

Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: This document contains custom code that cannot be loaded because the location is not in your trusted locations list: BO_Annexure_16062025.xlsx. If you trust this document you can save and open it from a location on your computer. For more information, see http://go.microsoft.com/fwlink/?LinkId=99104.

at Microsoft.VisualStudio.Tools.Office.Runtime.RuntimeUtilities.VerifyDocumentIsTrusted(String documentFullLocation, String documentName, OfficeVersion officeVersion)

at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.GetAssemblyDataFromManifests(String solutionLocation, String manifestLocator, String documentName, Boolean showUIDuringDeployment, CustomizationType customizationType, OfficeVersion officeVersion, IHostServiceProvider interopServiceProvider)

at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.CreateCustomizationDomainInternal(String solutionLocation, String manifestName, String documentName, Boolean showUIDuringDeployment, IntPtr hostServiceProvider, Boolean useFastPath, IntPtr& executor)

************** Loaded Assemblies **************

mscorlib

Assembly Version: 4.0.0.0

Win32 Version: 4.8.9310.0 built by: NET481REL1LAST_C

CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

Microsoft.VisualStudio.Tools.Office.Runtime

Assembly Version: 10.0.0.0

Win32 Version: 10.0.60910.0

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Office.Runtime/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Office.Runtime.dll

System.Core

Assembly Version: 4.0.0.0

Win32 Version: 4.8.9297.0 built by: NET481REL1LAST_C

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

System

Assembly Version: 4.0.0.0

Win32 Version: 4.8.9310.0 built by: NET481REL1LAST_C

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

Microsoft.VisualStudio.Tools.Applications.Hosting

Assembly Version: 10.0.0.0

Win32 Version: 10.0.60910.0

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Hosting/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Hosting.dll

Microsoft.VisualStudio.Tools.Applications.ServerDocument

Assembly Version: 10.0.0.0

Win32 Version: 10.0.60910.0

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.ServerDocument/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll

Microsoft.VisualStudio.Tools.Applications.Runtime

Assembly Version: 10.0.0.0

Win32 Version: 10.0.60910.0

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.dll

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Dora-T 1,810 Reputation points Microsoft External Staff Moderator
    2025-06-16T05:00:38.6033333+00:00

    Hi @Cheok

    Thank you for reaching out to the Microsoft Q&A forum. 

    Based on your description, it sounds like Office is blocking the custom code in your file because it's stored in a location that isn't currently marked as trusted. This is completely understandable, as it's an Office security feature designed to keep you safe. 

    You might be able to resolve this by adding your folder to the list of trusted locations. Here’s how to give it a try:" 

    • Open the Office app you're using (for example, Excel), but don’t open the file yet. 
    • Go to File > Options. 

    User's image

    • Select Trust Center > Trust Center Settings > Trusted Locations. 

    User's image

    • Click Browse to find the folder, select the folder where your file is saved, and then click OK. 

    User's image

    Please note, for your security, it's always advisable to only add folders that you are confident about and trust, particularly when dealing with files that contain custom code. 

    Feel free to let me know how it goes, I’m happy to help if anything comes up!


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".      

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.