1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: How do I create an excel template 2007 (.xltx) programatically in C# using ex

Discussion in 'Business Applications' started by renkumari, May 29, 2009.

Thread Status:
Not open for further replies.
  1. renkumari

    renkumari Thread Starter

    Joined:
    May 29, 2009
    Messages:
    2
    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."
    What is wrong with this code?

    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();
    /////////////////////////


    Any help is very much appreciated.
    Thanx in advance.
     
  2. renkumari

    renkumari Thread Starter

    Joined:
    May 29, 2009
    Messages:
    2
    Hi guys!
    The issue could be solved by replacing
    XlFileFormat.Template8
    with
    XlFileFormat.xlOpenXMLTemplate
    in Workbook.SaveAs().


    Regards
    renkumari
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Solved create excel
  1. estyMonsty
    Replies:
    2
    Views:
    383
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/830920

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice