Visio cannot open the file or a component in the file because it is corrupt (Visio 2016)

After upgrading a number of systems to Visio 2016, I started to hear more and more about old pre-2010 Visio files in VSD format that would no longer open and would throw the following error:

The strange thing was that the files were still launching without issue for users who were still on Visio 2010 and 2013.  The consensus as I searched around the Internet was that the older VSD files often had too many shaped embedded in them, and the fix was to open them in Visio 2010 or 2013, go through a process of removing unused shapes, and then saving in VSDX format.  Saving the file in the new format without removing the shapes would not resolve the issue.

I worked for a few hours on finding ways to be able to do this in newer versions of Visio, but never came up with a solution.  Instead, I found pieces of random VBScripts online where people were doing similar things, and then assisted users in converting these documents to the newer formats in bulk by writing a PowerShell script that essentially did what others were either doing manually or with VBS.  While I normally like to references my sources in my blog posts, unfortunately I didn’t bookmark the page where I found the most useful information about the Visio COM – so apologies to that author if he ever happens across this post.

The following script is not pretty.  It was a rush job to get a large number of users whom I’d just upgraded working again quickly.  I often pretty up my code before posting, but this time I’m giving it to you the way I originally wrote it.  You’re welcome to use it, modify it, redistribute it, and perhaps even make it a little nicer yourself.  As with all code you find online, backup your original files first, and always run in test before ever using on anything in production.

Edit Oct. 1, 2018: The previous version of this script contained errors and has since been resolved.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.