Solved

Execute code on Save

Posted on 2011-09-30
4
233 Views
Last Modified: 2012-05-12
How do I call a macro each time I save a workbook?
0
Comment
Question by:fitaliano
  • 2
4 Comments
 
LVL 12

Expert Comment

by:kgerb
ID: 36895629
Put this in the workbook module.  Change MyMacro to the name of the procedure you want to call.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Call MyMacro
End Sub

Open in new window


Kyle
0
 
LVL 33

Expert Comment

by:Mike Eghtebas
ID: 36895633
0
 

Author Comment

by:fitaliano
ID: 36903374
The suggested code doesn't work.  I put a breakpoint and it skips the routine.  Any suggestion?
0
 
LVL 12

Accepted Solution

by:
kgerb earned 500 total points
ID: 36903552
did you put it in the "workbook" module?  It won't work if you put it in a normal module.

code for workbook events goes in here
Kyle
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Excel 2013 Problem 12 48
VLOOKUP to a Closed Workbook 22 68
Formula to convert ranked data 2 11
MIN, using ARRAY 4 17
In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now