Save by VBA does not trigger Save Event

jfr92

New Member
Joined
Dec 11, 2013
Messages
13
I have a process that is to be triggered Before Save. Excel 2010 64-bit W7. When I open the workbook manually and request a save from the keyboard it works fine. When the same workbook is opened by another workbook and saved by that second workbook's VBA code, the Before Save process is not triggered. Is that not supposed to work?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
It should generally work - are you sure the first workbook doesn't disable events?
 
Upvote 0
Hi again. No, that's not the problem, thanks. I could make a copy of the process in workbook two and have it execute the code before it saves but that seems to be inelegant to say the least. Is there another event that can be triggered by a calling workbook? (BTW, the Before Close event produced the same non-behavior when the calling workbook closed the book with the to-be-event-triggered code.)
 
Upvote 0
If you close a workbook, its beforeclose event should be called unless something else is interfering. In my experience this is usually due to code using Application.Enableevents = False and forgetting to reset it, or Document Management software interference.
 
Upvote 0
I have never used applicationevents=false so that is not the issue. I'm not sure what Document Management software refers to. There is something wrong generally. Shellexecute works only half the time. When it fails it gives a code 29, "SE_ERR_DDEFAIL". When I restart the system, after closing everything, still Windows asks if I want to save changes to Book1 before restarting. Just now I closed everything and checked Task Manager before restarting. It says I have six copies of Excel in memory. Manually deleting them from TM avoided the restart routine asking me if I want to save.

In my research of these problems I found references to COM. One involved ShellExecute and another involved copies of closed Excel books still showing in Task Manager. The one regarding ShellExecute recommended using CoInitializeEx, however I was not able to call that function from my VBA code. Perhaps it must be initialized explicitly for C but is supposed to be automatic for VBA?
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top