How to delete VB code from an Excel sheet using C#?

Posted by Bashir Magomedov on Stack Overflow See other posts from Stack Overflow or by Bashir Magomedov
Published on 2010-06-01T10:14:13Z Indexed on 2010/06/01 10:23 UTC
Read the original article Hit count: 329

Filed under:
|
|
|
|

Does anyone know how to delete all VB code form an Excel workbook using C#? This code doesn’t work. It removes first (last one) VBComponent, but rises ArgumentException on second one.

        VBProject project = workbook.VBProject;
        int componentsCount = project.VBComponents.Count;

        for (int i = componentsCount; i >= 1; i--)
        {
            VBComponent component = project.VBComponents.Item(i);
            project.VBComponents.Remove(component);
        } 

Any suggestions? :)

© Stack Overflow or respective owner

Related posts about c#

Related posts about excel