Skip to content

Instantly share code, notes, and snippets.

@AnshulKuthiala
Last active December 21, 2018 14:37
Show Gist options
  • Save AnshulKuthiala/f49e7d9c545f2668637426551d2c232e to your computer and use it in GitHub Desktop.
Save AnshulKuthiala/f49e7d9c545f2668637426551d2c232e to your computer and use it in GitHub Desktop.
[Remove Customization] #ExcelHelper Remove document customization from document
//Add reference to using Microsoft.VisualStudio.Tools.Applications.ServerDocument
using Microsoft.VisualStudio.Tools.Applications;
private static void RemoveCustomiation(string filePath, int attempt)
{
int maxAttempt = 10;
try
{
ServerDocument.RemoveCustomization(filePath);
}
catch (IOException)
{
if (attempt <= maxAttempt)
{
attempt++;
Thread.Sleep(1000);
RemoveCustomiation(filePath, attempt);
}
else
{
throw new Exception("Unable to remove customization.");
}
}
catch (Exception)
{
throw;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment