Solved

Execute code on Save

Posted on 2011-09-30
4
238 Views
Last Modified: 2012-05-12
How do I call a macro each time I save a workbook?
0
Comment
Question by:fitaliano
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 34

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

617 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