'Returning the python Script from particular line
How Can i loop back the python script from particular line. This is about the refreshing an excel and I want to refresh it once in 2 hours.
import win32com.client as win32
import time
xlapp = win32.DispatchEx('Excel.Application')
wb = xlapp.Workbooks.Open('Excel path')
xlapp.visible = True
wb.RefreshAll()
time.sleep(10)
wb.Save()
wb.Close()
xlapp.Quit()
I don't want to close the excel file. So basically save it and loop back again after 2 hours and refresh and save... Repeat
How can I don that?
Solution 1:[1]
Since you've already imported time, you could build a loop with time.sleep(7200) (7200 seconds being two hours) that keeps saving. Although I don'T think it's a good idea to keep the file open throughout that time. What speaks against closing and re-opening it after two hours?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Schnitte |
