Visio Guy

Visio Discussions => Programming & Code => Topic started by: paulv45 on November 07, 2017, 02:49:29 AM

Title: Can't create reference to Visio Library in Visual Studio project
Post by: paulv45 on November 07, 2017, 02:49:29 AM
I am attempting to create an .exe that calls Visio. I did this many years ago and now am now trying to update using Visual Studio 2017.

The statement:
   Dim appVisio As Visio.Application
Produces the compile error:
   Type 'Visio.Application' is not defined.

This is understandable since I have not yet referenced the Visio library.
However, when I attempt to reference the library, Visual Studio appears to take the reference but when I go back to verify that it has been defined, it hasn't.

In Visual Studio 2017 I:

    File, New Project, Installed, Visual Basic, Windows Classic, Desktop, Console App.

    Project, Add Reference..., Microsoft Visio 16.0 Type Library

Repeating the Add Reference shows that it really hasn't taken.

Of course the compile error remains.

Anyone else able to build a .exe referencing Visio?

Thanks.

Paul
Title: Re: Can't create reference to Visio Library in Visual Studio project
Post by: paulv45 on January 01, 2018, 02:02:16 AM
Working with Visual Studio support here's where I ended up:

(1) Project, Add Reference...: Assemblies, Extensions: Microsoft.Office.Interop.Visio 15.0.0.0

(2) Project, Add Reference...: COM, Type Libraries: Microsoft Visio 16.0 Type Library 4.16 (Note that in my environment this reference appears not to stay selected when coming back into references to check, but it really is selected)

(3) In code, before Module line add: Imports Microsoft.Office.Interop

With these additions things work for me -- Dim appVisio as Visio.Application compiles and app runs.