Solved

Execute code on Save

Posted on 2011-09-30
4
235 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you how to use shortcut menus in the Access run-time environment.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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