View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default Run macro with BeforeSave Event

The first line needs to look like this

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

And you need to do some other checking, but I don't have time to help with
that part. I've got a fire of my own to put out. :) Hopefully someone
else can assist.
--
HTH,
Barb Reinhardt



"JDH" wrote:

Macro is in "ThisWorkbook"

Private Sub Workbook_BeforeSave()
ThisWorkbook.Save
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"C:\Mold Release Verification\QSA Mold Release Verification.htm",
FileFormat _
:=xlHtml, ReadOnlyRecommended:=True, CreateBackup:=False
Application.DisplayAlerts = True
End Sub

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

"Barb Reinhardt" wrote:

What's the code and where does it have an error.
--
HTH,
Barb Reinhardt



"JDH" wrote:

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