ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   troubles with ActiveWorkbook.Save (https://www.excelbanter.com/excel-programming/306664-troubles-activeworkbook-save.html)

Gabriele C[_4_]

troubles with ActiveWorkbook.Save
 
HI!
i'm having troubles with activeworkbook.save
I have a button that calls "closewb"macro
If I use this button,the file is closed WITHOUT saving anything
If I close by rightclick-close,or with the x in the topright corner, i
saves.Why?
I will be happy If anyone helps :)



Sub closewb()
ActiveWorkbook.Close
End Sub


Private Sub Workbook_BeforeClose(Cancel As Boolean)

Worksheets(1).Select
If Range("c2").Value = "EFFETTIVO" Or Range("f50").Value = "annulla
Then
ActiveWorkbook.Saved = True
Else: ActiveWorkbook.Save
End If

End Su

--
Message posted from http://www.ExcelForum.com


Gabriele C[_5_]

troubles with ActiveWorkbook.Save
 
Here I am...

I missed ":" while writing savechanges : = true

Now everything goes well...

It's strange ,bytheway....I didn't receive any kind of error...
thought that the beforeclose sub was less flexible...mmh,don't kno
what to think!

Bye

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 11:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com