How to overwrite an excel application without prompting the users..

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-05-14T03:53:17Z Indexed on 2010/05/14 7:04 UTC
Read the original article Hit count: 281

Filed under:
|
|

Can anyone help me on how can I overwrite the excel file without prompting the users in VB.Net..

I have try this code but It doesn't work..

Dim xlsApp As New Excel.Application
Dim xlsBook As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
Dim dir As String = Application.StartupPath & "\Template\SampleTemplate.xls"
xlsBook = GetObject(dir)
xlsSheet = xlsBook.Sheets("Per BPA Error Report")


xlsSheet.Range("C2:T2").Merge()

xlsApp.DisplayAlerts = False
xlsSheet.SaveAs(Application.StartupPath & "\Template\SampleTemplate.xls")
xlsBook = Nothing
xlsSheet = Nothing
xlsApp.Quit()

© Stack Overflow or respective owner

Related posts about excel

Related posts about overwriting