HariniReddy
HariniReddy

Reputation: 1

How to get VDX format from VSDX using Visio 2013 or higher?

Starting from Microsoft Visio 2013 support for VSD documents has been ended. Our App has a requirement to convert VSDX to VDX using Visio 2013 but I couldn’t find a way to do.

I tried to use Visio interop DLL to open invisible Visio App and tried to use SaveAs to save my VSDX as VDX. Code compiles and runs without any error and I get a .VDX file as output. When I try to view that generated VDX file using Visio viewer it fails. It says

Microsoft viewer cannot complete this operation

Wasn’t it generated as a healthy file?

We need to move away from Visio 2010 to Visio 2019. We would need to find a way to support both VSDX and VDX formats until all our apps are migrated. I have used below POC to convert .vsdx to .vdx or to convert .vsd to .vdx both of which dint work when i tried to view using Visio viewer . -

There were few articles where suggested me to use below POC to convert .VSDX to .VDX or to convert a .VSD to .VDX , both of which dint work. So .VSD to .VDX is not possible at all unless i use a Visio 2010 editor ?

       // Create Visio Application Object
        Visio.Application vsdApp = new Visio.Application();

        // Make Visio Application Invisible
        vsdApp.Visible = false;

        // Create a document object and load a diagram
        Visio.Document vsdDoc = vsdApp.Documents.Open(dataDir + "Drawing1.vsd");

        // Save the VDX diagram
        vsdDoc.SaveAs(dataDir + "SaveDiagramToVDXwithVSTO_out.vdx");   

Link referred - https://csharp.hotexamples.com/examples/Microsoft.Office.Interop.Visio/Application/-/php-application-class-examples.html

Upvotes: 0

Views: 2201

Answers (1)

Nikolay
Nikolay

Reputation: 12255

The "Save-As VDX" feature was really-really removed in Visio 2013. Even from the API. If you call .SaveAs passing name with .vdx extension what you actually get is .vsd binary file, just with extension .vdx. You can make sure of that by simply viewing the produced file in notepad - it's not xml.

When you try to load that file in the viewer, it tries to parse it as xml, but fails, because file is actually a binary file, thus you get this error.

If you need to support .vdx, stick to Visio 2010.

Upvotes: 2

Related Questions