Jean-Christophe,
Here is some sample code: set up your template so that the first sheet will contain the data (but is
currently empty) and extract the data that you want to graph onto another sheet using links.
Pasting the values will update those links and the graphs. The specific code to open your data file
depends on the structure - use the macro recorder. This shows how to schedule the next running of
the macro, and how to cancel it, too.
Option Explicit
Dim NextTime As Date
Sub GetData()
Dim myFileName As String
myFileName = "C:\folder\whatever.txt"
Workbooks.OpenText Filename:= _
myFileName, Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=True, Space:=False, Other:=False
ActiveSheet.Range("A1").CurrentRegion.Copy
ThisWorkbook.Sheets(1).Range("A1").PasteSpecial xlPasteValues
Application.DisplayAlerts = False
ActiveWorkbook.Close False
ThisWorkbook.SaveCopyAs "C:\StorageFolder\Filename" & Format(Now(), "yyyy-mm-dd-hh-mm") &
".xls"
ThisWorkbook.Sheets(1).Cells.ClearContents
NextTime = Now() + TimeValue("00:10:00")
Application.OnTime NextTime, "GetData"
End Sub
Sub CancelRead()
On Error Resume Next
Application.OnTime NextTime, "GetData", schedule:=False
End Sub
HTH,
Bernie
MS Excel MVP
Write a macro to import the text file and place the data as needed into a chart. Then use the
Application.Ontime method at the end of the macro to schedule itself for 10 minutes in the future.
Thanks Bernie.
Unfortunately I'm not advanced enough to do that from scratch.
May I ask if you have a sample code for this macro ?