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
46 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
[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
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 51

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

739 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