deltanovember
deltanovember

Reputation: 44051

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 to CSV every second. How can I do this in VBA?

Upvotes: 1

Views: 497

Answers (1)

ktdrv
ktdrv

Reputation: 3673

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)

Upvotes: 1

Related Questions