ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Example After Save Event (https://www.excelbanter.com/excel-programming/343922-example-after-save-event.html)

Steph[_6_]

Example After Save Event
 
Hi. Does anyone have an example of some 'After Save' event code? I
understand it doesn't exist, but can be accomplished by using a Before Save
event and cancelling the Event, then doing something else? Any help would
be appreicated. Thanks in advance!



quartz[_2_]

Example After Save Event
 
Something like the following may be what you are after:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
'<Optional - Your other code here
ThisWorkbook.Save
'<Optional - More of your other code here
End Sub

The above must reside in the "ThisWorkbook" module, which is where I copied
the "Private Sub..." line from. If you go into that module and select
"Workbook" from the top left-hand side drop down and then select "BeforeSave"
from the right-hand drop down it writes the basic subroutine for you.

HTH.

"Steph" wrote:

Hi. Does anyone have an example of some 'After Save' event code? I
understand it doesn't exist, but can be accomplished by using a Before Save
event and cancelling the Event, then doing something else? Any help would
be appreicated. Thanks in advance!




Jim Rech

Example After Save Event
 
I think you need to disable events before your save (and enable after) or
you'll be in an endless loop.

--
Jim
"quartz" wrote in message
...
| Something like the following may be what you are after:
|
| Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
| Cancel = True
| '<Optional - Your other code here
| ThisWorkbook.Save
| '<Optional - More of your other code here
| End Sub
|
| The above must reside in the "ThisWorkbook" module, which is where I
copied
| the "Private Sub..." line from. If you go into that module and select
| "Workbook" from the top left-hand side drop down and then select
"BeforeSave"
| from the right-hand drop down it writes the basic subroutine for you.
|
| HTH.
|
| "Steph" wrote:
|
| Hi. Does anyone have an example of some 'After Save' event code? I
| understand it doesn't exist, but can be accomplished by using a Before
Save
| event and cancelling the Event, then doing something else? Any help
would
| be appreicated. Thanks in advance!
|
|
|



quartz[_2_]

Example After Save Event
 
Oops! Thanks for correction! Sorry for confusion.

"Jim Rech" wrote:

I think you need to disable events before your save (and enable after) or
you'll be in an endless loop.

--
Jim
"quartz" wrote in message
...
| Something like the following may be what you are after:
|
| Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
| Cancel = True
| '<Optional - Your other code here
| ThisWorkbook.Save
| '<Optional - More of your other code here
| End Sub
|
| The above must reside in the "ThisWorkbook" module, which is where I
copied
| the "Private Sub..." line from. If you go into that module and select
| "Workbook" from the top left-hand side drop down and then select
"BeforeSave"
| from the right-hand drop down it writes the basic subroutine for you.
|
| HTH.
|
| "Steph" wrote:
|
| Hi. Does anyone have an example of some 'After Save' event code? I
| understand it doesn't exist, but can be accomplished by using a Before
Save
| event and cancelling the Event, then doing something else? Any help
would
| be appreicated. Thanks in advance!
|
|
|




Steph[_3_]

Example After Save Event
 
Ok, so if I combine the posts, my event will look like the following?:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
'<Optional - this would be true before save code
application.enableevents = false
ThisWorkbook.Save
application.enableevents = true
'<Optional - this would be after save code
End Sub

"quartz" wrote in message
...
Oops! Thanks for correction! Sorry for confusion.

"Jim Rech" wrote:

I think you need to disable events before your save (and enable after) or
you'll be in an endless loop.

--
Jim
"quartz" wrote in message
...
| Something like the following may be what you are after:
|
| Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
| Cancel = True
| '<Optional - Your other code here
| ThisWorkbook.Save
| '<Optional - More of your other code here
| End Sub
|
| The above must reside in the "ThisWorkbook" module, which is where I
copied
| the "Private Sub..." line from. If you go into that module and select
| "Workbook" from the top left-hand side drop down and then select
"BeforeSave"
| from the right-hand drop down it writes the basic subroutine for you.
|
| HTH.
|
| "Steph" wrote:
|
| Hi. Does anyone have an example of some 'After Save' event code? I
| understand it doesn't exist, but can be accomplished by using a
Before
Save
| event and cancelling the Event, then doing something else? Any help
would
| be appreicated. Thanks in advance!
|
|
|







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

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