Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
61 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 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

877 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