View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
ETLahrs ETLahrs is offline
external usenet poster
 
Posts: 17
Default Run macro with BeforeSave Event

Just looking at the code real quick, it looks to me that the first line in
the sub is going to cause a problem:

ThisWorkbook.Save

This event is being called because the file is about to be saved, so after
it runs the file will save and that line is unnecessary. I would also think,
and I could be wrong, but if before it saves it runs this sub, when you try
to save it, it wants to run through it again.

Just my quick thoughts. Hope it helps.

"JDH" wrote:

It is in "ThisWorkbook" module

When I use: "Private Sub Workbook_BeforeSave()"

Error message: Compile error - Precedure declaration dose not match or
procedure having the same name.


When I use: "Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean,
Cancel As Boolean)"

I receive a message "Microsoft Excel for windows has encountered a problem
and needs to close.

"Chip Pearson" wrote:

Specifically what error message do you get? RunTime error? Compiler error?
What line of code is highlighted by the debugger when the error occurs?


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"JDH" wrote in message
...
Hi again,

I have a macro that I am running on a BeforeClose event and I need it to
run
on a Workbook_BeforeSave event. When I click Save I receive an error
message.
As of now I having to use:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
mymarcro
End Sub