Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi - I have a .Net 2.0 Windows Application and I want to open a Visio 2007 document when the user chooses a date from a date picker. Here's my code:

using visio = Microsoft.Office.Interop.Visio;
string docPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + @"F:\EAS\FloorPlan.vsd";
visio.Documents.Open(docPath);

However, when I compile I get the error message, "The type or namespace 'Office' does not exist in the namespace 'Microsoft'"

I've got Office 2007 installed on this machine, and I've installed the Microsoft XP Primary Interop Assemblies for Office 2007. I've added a reference in my VS 2005 project for the Microsoft Visio 12.0 Type Library. When I do this last step, Microsoft.Office.Core shows up under References in the VS Solution Explorer, but it has a yellow triangle with an exclamation point next to it.

What am I missing?

Thanks!
Posted

Have you tried adding a reference to the primary interop assembly for visio? (Not the type library)

Remember that visio is a 32-bit application

Download from here:
2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies [^]

After installation the assemblies should be visible as .Net assemblies

Regards
Espen Harlinn
 
Share this answer
 
v3
Never mind - I just deleted and re-added the Reference and I've got rid of that compile error. I've got another error now, but it's not related to the PIA's.

Thanks for your help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900