Hi,
I have a python script that is reading an excel file every 5 seconds. The excel file needs to be saved for any changes to be read by python. I have a macro running in excel to do this. I have set .EnableEvents and .DisplayAlerts to False however occasional I will be prompted by the save as dialogue in a new instance of excel which has opened alongside my original file with a name something like 1EDA3000
I only get this when I'm running the python script after a about 20mins or so. I guess this is a write and read problem with python reading the file excel is writing to.. ?
Would anyone know how to go about preventing this behaviour..?
Code in standard Module
Public dTime As Date
Sub AutoSaveAs()
dTime = Time + TimeValue("00:00:05")
With Application
.OnTime dTime, "AutoSaveAs"
.EnableEvents = False
.DisplayAlerts = False
ThisWorkbook.Save
.EnableEvents = True
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnTime dTime, "AutoSaveAs", , False
End Sub
In ThisWorkbook Module;
Private Sub Workbook_Open()
dTime = Time + TimeValue("00:00:05")
Application.OnTime dTime, "AutoSaveAs"
End Sub
THANKS!
Bookmarks