开发者

How can I get Excel to programmatically write to CSV?

At the moment my spreadsheet reads financial data. I would like to programmatically dump this 开发者_如何学Cto CSV every second. How can I do this in VBA?


Something like this should work:

Sub SetTimeout()
    Application.OnTime Now + TimeValue("00:00:30"), "SaveAsCSV"
End Sub

Sub SaveAsCSV()
    Calculate
    ActiveWorkbook.SaveAs Filename:="book1.csv", FileFormat:=xlCSV, CreateBackup:=False
    Call SetTimeout
End Sub

Just call SetTimeout() whenever you want to start saving and it will do so every 30 seconds from then on (hence the Now + TimeValue("00:00:30") part)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜