I created an vb excel-document project in visual studio 2012 and I want to expose vb.net code to my VBA macros. I found this walkthrough http://msdn.microsoft.com/en-US/library/vstudio/bb608609.aspx but i get an error when i try this.
With EnableVBACallers set to false everything runs fine but after enabling this property Visual Studio throws an error when i try to compile my excel document.
Error(Translated by me):
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(623,9): error VST3213: WIN32-resources in assembly "obj\Debug\TestMappe.dll" could not be updated. The system can not find the specified file.
What causes this error? The file "Microsoft.VisualStudio.Tools.Office.targets" exists.
In my code i can find this change with EnableVBACaller set to true: Visual Studio changes my class definition from "Public Class ThisWorkbook" to this "<Microsoft.VisualBasic.ComClassAttribute()> <System.Runtime.InteropServices.ComVisibleAttribute(True)> Public Class ThisWorkbook"
When I set EnableVBACallers to true the property ReferenceAssemblyFromVbaProject is set to true automatically, when i set it back to false manually my code does compile but is not exposed. So ReferenceAssemblyFromVbaProject musst cause this error
Someone knows how to fix this? Thanks for your help.
Please make sure that you did all the steps described in the Walkthrough: Calling Code from VBA in a Visual Basic Project . Did you add the location of the document to the Microsoft Office Trusted Location (see in the host app)?
Finally, do you run Visual Studio as an administrator (with elevated privileges)?
I did all steps of the waklthrough and marked my whole project folder(with subfolders) as a trusted location but the error still exists.
I don´t understand why visual studio says file "obj\Debug\TestMappe.dll" can´t be updated. The file exists visual studio is started with elavated privilidges. Visual studio can access this file definitly, it is build everytime i start the build process.
I started a new project from scratch today. This time I even to a word document instead of excel just to do really everything like that walkthrough but I get the same error. Could somebody else follow those stepts and if it works send me that project to see if I am too dumb or if it´s visual studio/ windows 8 fault.
Walkthrough see the link above. I´m not allowed to post links in my answer although i could in my initial post... weird.