Save visio 2016 diagram in the vsd format programmatically

126 Views Asked by At

I am migrating to Visio 2016 drawing control from Visio 2010. When I save a new file as .vsd outside the main Visio application it is throwing an exception. However, the file is saved on the given location. I save the file as .vsd for backward compatibility. This would affect reloading/opening the same new file and it is throwing an exception. Below snippet works well with Visio 2010.

BOOL Doc::SaveAs(vbPath)
{
    success = TRUE;

    if (!SUCCEEDED(CVisioDocument::SaveAsEx(vbPath, visSaveAsWS)))   //SaveAsEx return 0
    {
        success = FALSE;
    }

    // Now do a save to get the drawing on the Most Recently Used list
    short saveRc=0;
    if (!SUCCEEDED(CVisioDocument::Save(&saveRc)))  //Get exception here in Save method
        ASSERT(0);

    return success;
}

CVisioDocument::SaveAsEx(vbPath, visSaveAsWS) return "0". It means successfully saved new document. But after I try, CVisioDocument::Save(&saveRc) throws an exception, because until a document has been saved, the Save method generates an error. On the other hand, I can save a new document in the main Visio application without any exception. That's file is opening in the main Visio application.

So, Can you help with how can I get rid out of the above problem?

I find out someone has also a similar problem in Visio 2013, http://visguy.com/vgforum/index.php?topic=4819.0

0

There are 0 best solutions below