ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problems with Workbook Before Save Event (https://www.excelbanter.com/excel-programming/437862-re-problems-workbook-before-save-event.html)

Ryan H

Problems with Workbook Before Save Event
 
This is the code that I had to use.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

With ThisWorkbook
.IsAddin = True
.Save
End With

End Sub

I find it odd that I have to put ThisWorkbook.Save in the BeforeSave Event.
If I don't change the IsAddIn property the ADD IN workbook saves just fine,
but when I change the property it won't save. Could this be a bug in Excel
or does Excel do this for a particular reason? What is a good resource to
ask Microsoft if this is a bug?

Keep in mind that the ADD IN workbook is referenced by the QUOTES workbook,
thus the ADD IN workbook is hidden and contains all the code to manipulate
data in QUOTES. The only thing in QUOTES is a bunch of buttons which call
Subs in ADD IN.
--
Cheers,
Ryan


"JLGWhiz" wrote:

Try adding a save line in:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If Cancel = False Then ThisWorkbook.IsAddin = True
ThisWorkbook.Save
End Sub




"Ryan H" wrote in message
...
I have a workbook named "QUOTES" that references another workbook named
"ADD
IN". ADD IN is saved as an add in, aka IsAddIn = True. I have a button
in
QUOTES that changes the IsAddIn property = False which exposes the ADD IN
worksheets for editting by the user. Then when the user makes his edits
and
clicks the save button I want the IsAddIn property set back to True thus
re-hidding the workbook to its orginal state. I do this in the BeforeSave
Event.

This is the problem. I make my edits, click save in ADD IN, the workbook
is
hidden and everything seems fine. But for some reason when I close QUOTES
I
get prompted "Do you want to save ADD IN?" If I click NO, my edits are
not
saved. So for some reason ADD IN isn't saving. Why?

Sub cmbEditAddIn_Click()

' show add in workbook
With ThisWorkbook
.IsAddin = False
.Activate
End With

End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If Cancel = False Then ThisWorkbook.IsAddin = True

End Sub
--
Cheers,
Ryan



.



All times are GMT +1. The time now is 12:02 PM.

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