Saurabh.Gupta

The following code works fine, when I manually create an xlt file

However it fails, when I generate the .xlt file programatically, with the exception as in the subject.

Globals.ThisWorkbook.Sheets.Add(Type:=absoluteFilePath) '.xlt file

ref bug: http://support.microsoft.com/default.aspx scid=kb;en-us;210684&Product=xlw

The code that I use to generate the .xlt programatically is:

Globals.ThisWorkbook.RemoveCustomization() 'such that, saved copy does not have customization

Globals.ThisWorkbook.ActionsPane.Clear()

Globals.ThisWorkbook.Application.DefaultSaveFormat = Excel.XlFileFormat.xlTemplate

Globals.ThisWorkbook.SaveCopyAs(absoluteFilePath) 'fully qualified path to a new .xlt

Globals.ThisWorkbook.ActionsPane.Show()



Re: Visual Studio Tools for Office "Add method of Sheets class failed" - adding sheets from an XLT into Excel workbook

Dennis Wallentin

Hi,

Is the template You're trying to create protected in anyway If yes then You should remove the protection.






Re: Visual Studio Tools for Office "Add method of Sheets class failed" - adding sheets from an XLT into Excel workbook

Saurabh.Gupta

I don't think it is protected, NO.

I did nothing to protect it, it has been created programatically, as you see in my post.