Excel create an excel template 2007 (.xltx) in C# using excel automation

Joined
May 30, 2009
Messages
1
Reaction score
0
I need to create an excel 2007 template (.xltx) from my c# code. I am using excel automation to create.

The following code creates an xltx file. But when I open, I get an empty excel application with an error message "Excel cannot open the file 'NewTemplate.xltx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."

code:
/////////////////
workbook = workbooks.Add(System.Reflection, Missing.Value);

workbook.SaveAs("D:\\NewTemplate.xltx", office2007.XlFileFormat.xlTemplate8, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, false, office2007.XlSaveAsAccessMode.xlNoChange, System.Reflection.Missing.Value, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);

workbooks.Close();
excelApplication.Quit();
/////////////////////////

Can anyone please help me to find the problem in creating a new xltx template file.
Many thanx in advance.

kumari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top