none
Opening Existing Visio Document in C# Displays Empty Document RRS feed

  • Question

  • Hi,

    I have embedded a Visio Drawing object in my C# application. I am trying to open an existing .vsd file in the drawing control. No exceptions are thrown, but all I ever get is a blank document. Could I please have some help? This should be an easy thing to do, but it is really holding me up.

    public Form1()
    {
          InitiliazeComponent();
          this.axDrawingControl1.Focus();
          this.axDrawingControl1.Document.Application.Documents.OpenEx(@"C:\Source\Tactic.vsd", (short)VisOpenSaveArgs.visOpenCopy);
    }

    I have also looked at the SDK 2007 Samples Library and have opying the OpenDocumentSample class. I have debugged the code, and the paths are correct. The outcome is the same - a blank document results.

    public Form1()
    {
          InitiliazeComponent();
          this.axDrawingControl1.Focus();
          OpenDocumentSample.DemoDocumentOpen(this.axDrawingControl1.Document.Application,
                       @"C:\Source\All Shapes.vss",
                       @"C:\Source\Tactic.vsd",
                       @"C:\Source\Hidden Document.vsd");
    }

    Thanks,

    David

    Tuesday, July 24, 2012 7:12 AM

Answers

  • The way you put a document into the control is (vb)

    drawingcontrol = AxDrawingControl1

    me.drawingcontrol.src = me.txtfilename.text

    al


    If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Al Edlund Visio MVP


    • Edited by Al Edlund Tuesday, July 24, 2012 12:13 PM
    • Marked as answer by oxtrot Wednesday, July 25, 2012 7:17 AM
    Tuesday, July 24, 2012 11:25 AM

All replies

  • The way you put a document into the control is (vb)

    drawingcontrol = AxDrawingControl1

    me.drawingcontrol.src = me.txtfilename.text

    al


    If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Al Edlund Visio MVP


    • Edited by Al Edlund Tuesday, July 24, 2012 12:13 PM
    • Marked as answer by oxtrot Wednesday, July 25, 2012 7:17 AM
    Tuesday, July 24, 2012 11:25 AM
  • Thanks, that does seem to work. I am still confused as to why OpenEx does not work, considering that it is used in examples provided by the SDK, but since another technique works perhaps it doesn't matter too much.

    Cheers,

    David

    Wednesday, July 25, 2012 7:19 AM
  • The only drawingcontrol sample in the visio sdk (all of them) is a C# demo (OfficePlanSample) and it uses this

    // Open the new document.

    drawingControl.Src = fileName;

    drawingControl.Document.Saved = true;

    It's a good sample to learn from.

    I ported it over to vb.net and decided to play wpf rather than winforms

    networkplansample.codeplex.com

    al


    If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Al Edlund Visio MVP

    Wednesday, July 25, 2012 12:14 PM