Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Why system asks me to save change even after I call save method(VB.NET)

I used below code to open and fill an Excel file automaically. After that, save it.
However, after I call Workbook.SaveAs(Or Save), when I close the Excel file. I always be asked "The content of this file is changed, do you want to save it?
But the content has already been saved indeed
Then why that message is showed? How to clear it?

Dim ExcelForm As New Excel.Applicatio
Dim exwbook As Excel.Workboo
Dim exsheet As Excel.Workshee
Dim file As New FileInfo("C:\template.xls"

If file.Exists = True The
file.Delete(
End I

Dim fs As FileStream = file.Create(
fs.Close(

ExcelForm = CreateObject("Excel.Application"
ExcelForm.Visible = Tru

exwbook = ExcelForm.Workbooks.Open("C:\template.xls"
exsheet = exwbook.Worksheets("template"

exsheet.Cells(1, 1) = ... ..

exwbook .SaveAs("C:\template.xls) 'Or exsheet.Save(

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Why system asks me to save change even after I call save method(VB.NET)

steellock,

Use this to close the workbook:
exwbook.Close False

HTH,
Bernie
MS Excel MVP

"steellock" wrote in message
...
I used below code to open and fill an Excel file automaically. After that,

save it.
However, after I call Workbook.SaveAs(Or Save), when I close the Excel

file. I always be asked "The content of this file is changed, do you want to
save it?"
But the content has already been saved indeed.
Then why that message is showed? How to clear it?

Dim ExcelForm As New Excel.Application
Dim exwbook As Excel.Workbook
Dim exsheet As Excel.Worksheet
Dim file As New FileInfo("C:\template.xls")

If file.Exists = True Then
file.Delete()
End If

Dim fs As FileStream = file.Create()
fs.Close()

ExcelForm = CreateObject("Excel.Application")
ExcelForm.Visible = True

exwbook = ExcelForm.Workbooks.Open("C:\template.xls")
exsheet = exwbook.Worksheets("template")

exsheet.Cells(1, 1) = ... ...

exwbook .SaveAs("C:\template.xls) 'Or exsheet.Save()



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Why system asks me to save change even after I call save method(VB.NET)

Thank you, Bernie!
In fact, we may only set Saved property after call Save method.
Below code is worked.

ExcelForm = CreateObject("Excel.Application")
ExcelForm.Visible = True

exwbook = ExcelForm.Workbooks.Open("C:\template.xls")
exsheet = exwbook.Worksheets("template")

... ...

exwbook.Save()
exwbook.Saved = True


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Each time I close an Excel file, it asks if I want to save. Doug Bell Excel Discussion (Misc queries) 4 July 24th 07 07:44 PM
Excel asks to save an unchanged document. Why? kkp Excel Discussion (Misc queries) 9 April 27th 06 08:05 PM
excel 02 always asks "save changes?" when closing unaltered file 6foot6 Excel Discussion (Misc queries) 1 February 16th 06 07:41 PM
why excel 2003 always asks to save or not Dino Hsu Excel Discussion (Misc queries) 2 February 12th 06 12:26 AM
System asks to save when no changes made? Megan[_2_] Excel Programming 2 January 8th 04 05:34 PM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"