Is there a way to use Visio Viewer 2007 in a WinForm application without havinf Visio 2007 installed on the machine?
I've tried an example on MSDN (http://msdn.microsoft.com/en-us/library/dd392798.aspx) but I'm gettinh the message "WindowLess ActiveX control not supported".
I'm following the exact instructions in the article, but it's not working.
I'm using VS 2008 on Vista.
Anyone having a working example of Visio viewer in a Winform? (Without Visio on the machine, of course)
I'm programming in VB but I've tried the example in C# to be sure I was doing the right thing.
Thanks
public partial class Form1 : Form { private AxVisioViewer.AxViewer viewer; /// <summary> /// The Visio Viewer OM /// </summary> public AxVisioViewer.AxViewer Viewer { get { return this.viewer; } } public Form1() { this.InitializeComponent(); this.Resize += new EventHandler(this.UpdateSize); this.viewer = new AxVisioViewer.AxViewer(); this.Controls.Add(this.viewer); this.viewer.CreateControl(); this.viewer.Location = new Point(0, 0); this.UpdateSize(null, null); } public void UpdateSize(object obj, EventArgs ea) { this.viewer.ClientSize = new Size(this.ClientSize.Width - 150, this.ClientSize.Height - 150); } private void Form1_Load(object sender, EventArgs e) { this.viewer.Load("C:\\users\\username\\documents\\viewer\\test.vsd"); } }
Imports AxVisioViewerPublic Class Form1 Private TheViewer As AxViewer Public Sub New() InitializeComponent() TheViewer = New AxViewer() TheViewer.Dock = DockStyle.Fill Me.Controls.Add(TheViewer) TheViewer.CreateControl() TheViewer.Location = New Point(0, 0) End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ofd As New OpenFileDialog() ofd.CheckFileExists = True ofd.CheckPathExists = True ofd.DefaultExt = ".vsd" ofd.Multiselect = False If (ofd.ShowDialog() = Windows.Forms.DialogResult.OK) Then TheViewer.Load(ofd.FileName) TheViewer.Refresh() End If ofd.Dispose() End Sub Private Sub LoadVisioDrawing() Dim ofd As New OpenFileDialog() ofd.CheckFileExists = True ofd.CheckPathExists = True ofd.DefaultExt = ".vsd" ofd.Multiselect = False If (ofd.ShowDialog() = Windows.Forms.DialogResult.OK) Then TheViewer.Load(ofd.FileName) TheViewer.Refresh() End If ofd.Dispose() End SubEnd Class
How silly of me, I had the old 2005 version of the viewer installed, but I was using the 2007 DLLs!
So I've installed the 2007 viewer and it's working now.
Open in new window