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

非 Y 不嫁゛ 提交于 2020-01-05 04:02:12

问题


Question: How to save ALL Excel files every given time period - say every minute or every 10 seconds ?

Related: here How to save Excel file every say minute? 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. Also that would not work if I need to save every 10 seconds.


回答1:


To save all open excel files every 10 seconds, you can use this code. You can assign it to shape and run it from one of the excel files.

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


来源:https://stackoverflow.com/questions/46550958/how-to-save-all-excel-files-every-say-minute-10-seconds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!