raoulb 0 Newbie Poster

I use VB .net to create Excel 2003 workbooks (.xls) based on a template (.xlt).
Currently, I make a copy of the template (xlReportName = C:\VisualStudioDotNetProjects\VisualBasic\MillsReport\Reports\MediumMi ll200807.xls
and xlReportTemplate = C:\VisualStudioDotNetProjects\VisualBasic\MillsReport\MillReportyyyymm .xlt
both are stingbuilders):

With xlReportName
'Create new report(make copy of template).
File.Copy(xlReportTemplate.ToString, .ToString)
'Make the file writeable.
File.SetAttributes(.ToString, FileAttributes.Normal)
File.SetCreationTime(.ToString, Now)
File.SetLastAccessTime(.ToString, Now)
File.SetLastWriteTime(.ToString, Now)
End With

This works 100% and the workbook file is created.

The worksheets are then updated with data:

Try 'Excel loop.
xlApplication = CreateObject("Excel.application")
xlApplication.Visible = True
xlApplication.Workbooks.Open(xlReportName.ToString)

'Update worksheets with data.

....

xlApplication.Workbooks(1).Save()

GenerateMillReport = True

Catch EX As Exception
ErrorMessage(cModuleName & "GenerateMillReport Excel Loop", _
"Exception error", _
ex.message)
GenerateMillReport = False

Finally
xlTerminateExcel(xlApplication)

End Try

The issue comes at save time: Excel tries to save the workbook as MediumMill2008071.xls (notice the extra 1). It looks like it still sees the report file as a template! However, if I open the file manually with Excel, make changes and save it, Excel happily does so with the original name (without extra 1). What am I missing?