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
39 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 20

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 50

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

821 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