简体   繁体   English

如何每隔一分钟/ 10秒保存所有Excel文件?

[英]How to save ALL Excel files every say minute / 10 seconds?

Question: How to save ALL Excel files every given time period - say every minute or every 10 seconds ? 问题:如何在每个给定时间段保存所有Excel文件 - 比如每分钟或每10秒?

Related: here How to save Excel file every say minute? 相关:这里如何保存Excel文件每说一分钟? a way to save given file is described. 描述了一种保存给定文件的方法。 But if I have many files it is a problem to process like that. 但是,如果我有很多文件,那么处理就像是一个问题。

Remark: In case if I need to save every minute - I can use Excel's autosave, but autosave is is in *.xlsb format which I have a problem reading by Python, also several files are created and it is not clear what file is saved in what moment. 备注:如果我需要保存每一分钟 - 我可以使用Excel的自动保存,但自动保存是* .xlsb格式,我有一个Python读取问题,也创建了几个文件,不清楚保存了什么文件在什么时候。 Also that would not work if I need to save every 10 seconds. 如果我需要每10秒钟保存一次,这也行不通。

To save all open excel files every 10 seconds, you can use this code. 要每10秒保存所有打开的 Excel文件,您可以使用此代码。 You can assign it to shape and run it from one of the excel files. 您可以将其指定为shape并从其中一个excel文件运行它。

Sub Save1()
Dim xWb As Workbook
Application.DisplayAlerts = False
For Each xWb In Application.Workbooks
        If Not xWb.ReadOnly And Windows(xWb.Name).Visible Then
            xWb.Save
        End If
    Next
Application.DisplayAlerts = True

Application.OnTime Now + TimeValue("00:00:10"), "Save1"
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM