Click here to Skip to main content
15,887,331 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I have written the below code that open my excel file and save it as text file

Dim xl As New Excel.Application
       Dim xlBook As Excel.Workbook = xl.Workbooks.Open("C:\ExcelData.xlsx")
       Dim xlSheet As Excel.Worksheet = xlBook.Sheets("Sheet1")

       xlSheet.SaveAs("C:\Data.txt", Excel.XlFileFormat.xlTextWindows)

       xlBook.Close



The problem is after it save the file i9t prompt me do you want to save changes and when I click Yes it overwrite the file with the latest opned sheet from the excel.

How can I stop it from overwriting and stop it from prompt me for changes?
Posted
Comments
Karen Mitchelle 13-Feb-14 4:21am    
As I have understood it, when you save the xls file, it was only renamed as "Data.txt" but it is still an xls file. Maybe, use a streamwriter..

1 solution

I solve it mtself by adding the below code at begining:


VB
xl.DisplayAlerts = False
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900