Solved

Dear Rgonzo please help making the code work in personal workbook to enforce it on any active workbook.

Posted on 2016-11-23
3
21 Views
Last Modified: 2016-11-23
I had this question after viewing VBA to automatically save the workbook every 2 minutes.

the code below works for single workbook, how this can be changed so that the auto save works on any activeworkbook instead of thisworkbook.?

thanks a million

Private Sub Workbook_Open()
Application.OnTime Now + TimeValue("00:02:00"), "SaveMe"
End Sub



Sub SaveMe()
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True

Application.OnTime Now + TimeValue("00:02:00"), "SaveMe"
End Sub

Open in new window

0
Comment
Question by:excelismagic
3 Comments
 
LVL 19

Expert Comment

by:darbid73
ID: 41898974
I am not up with Excel VBA and their might be some way of creating a file with VBA code which Excel will read.

The only method I know in which you can have code running for the whole Excel Application and thus on all Workbooks is to make an Application Level addin with VSTO.

This is not easy for beginners, but you can always ask questions here.
0
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41898986
the code in the personal. workbook

Private Sub Workbook_Open()
Application.OnTime Now + TimeValue("00:02:00"), "SaveMe"
End Sub

Open in new window



Sub SaveMe()
Application.DisplayAlerts = False
ActiveWorkbook.Save
Application.DisplayAlerts = True

Application.OnTime Now + TimeValue("00:02:00"), "SaveMe"
End Sub

Open in new window

0
 
LVL 3

Author Closing Comment

by:excelismagic
ID: 41899016
thanks alot
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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

760 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

18 Experts available now in Live!

Get 1:1 Help Now