Trying to open a excel template and rename or save to new location
Posted
by JPJedi
on Stack Overflow
See other posts from Stack Overflow
or by JPJedi
Published on 2010-03-29T12:43:45Z
Indexed on
2010/03/29
13:23 UTC
Read the original article
Hit count: 253
I get the following error message when I try the following:
Dim XL As New Microsoft.Office.Interop.Excel.Application
XL.Visible = True
XL.Workbooks.Open(XLTemplatePath)
XL.SaveWorkspace(XLSaveReportPath)
XL.Workbooks.Close()
XL.Workbooks.Open(XLSaveReportPath)
"Excel cannot open the file 'ContactReports.xlsx' 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 I would like to do is Open a excel file that is the XLTemplatePath and the either rename or save the file at the XLSaveReportPath and then use that renamed/saved file to fill the report out.
I am using Visual Studio 2008 in VB.NET
© Stack Overflow or respective owner