Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)))
    {
        success = FALSE;
    }

    // Now do a save to get the drawing on the Most Recently Used list
    short saveRc=0;
    if (!SUCCEEDED(CVisioDocument::Save(&saveRc)))  //exception in Save 
        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 anyone help with how can I get rid out of the above problem?

What I have tried:

I find out someone has also a similar problem in Visio 2013, http://visguy.com/vgforum/index.php?topic=4819.0
Posted
Comments
CHill60 1-May-20 4:39am    
Do you want to tell us what the exception actually is?
Did you try all of the suggestions on the link you gave? Do you get the same/different errors?
You are referring to .vsd files, but 2016 saves .vsdx files - could that be your problem?
Sagar SLS 1-May-20 7:42am    
Right now, I caught exception in a special catch block called ‘catch all’ catch(…) that can be used to catch all types of exceptions. So did not specify you what was the actual exception. I will update you if I get that specific exception type.

I haven't tried all suggestions but I believe that I will get the same behavior as he got.

Yes, I am referring to .vsd files and here SaveAsEx() however store the .vsd file given location but Save() gives exception. But I am not sure 2016 tries to saves as .vsdx and that causes the problem.
CHill60 4-May-20 5:44am    
2016 does use .vsdx. You said in your question "it is throwing an exception." What is that exception?
Sagar SLS 5-May-20 5:53am    
I have tried to get details of exception by catching the exception but it always throws in catch(...) so an exception is the unknown (not standard exception).
CHill60 5-May-20 6:02am    
Try removing your try-catch so that the exception is displayed. Or stick a message in there. You say it is throwing an exception so you must have seen something! You are not helping us to help you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900