Sargad_Strut
New Member
- Joined
- Mar 28, 2014
- Messages
- 44
Hi guys,
So this is what I'm trying to do. I've created a workbook that pulls data from an Access query, updates the data from an external source, and then creates a text file (with some dalay for the data to update) that will be imported and rewrite current values in the Access database.
In an ideal world I would like this to run say every five minutes, without noticing. I have tested to run the Workbook via the Scheduler, bud I'd like to make it smoother than that.
Is there any way I could run this without noticing? Any kind of input, even if it extends beyond VBA coding would be very much appreciated!
Private Sub Aut
pen()
Application.OnTime Now + TimeValue("00:00:05"), "GenerateTextfile"
End Sub
Sub GenerateTextfile()
Dim FilePath As String
Dim CellData As String
Dim LastCol As Integer
Dim LastRow As Integer
LastCol = 3
LastRow = Blad2.Range("F2").Value
Blad2.Range("A2").Activate
CellData = ""
FilePath = Application.DefaultFilePath & "\MyFile.txt"
Open FilePath For Output As #2
For i = 1 To LastRow
For j = 1 To LastCol
If j = LastCol Then
CellData = CellData + Trim(ActiveCell(i, j).Value)
Else
CellData = CellData + Trim(ActiveCell(i, j).Value) + vbTab
End If
Next j
Write #2, CellData
CellData = ""
Next i
Close #2
End Sub
So this is what I'm trying to do. I've created a workbook that pulls data from an Access query, updates the data from an external source, and then creates a text file (with some dalay for the data to update) that will be imported and rewrite current values in the Access database.
In an ideal world I would like this to run say every five minutes, without noticing. I have tested to run the Workbook via the Scheduler, bud I'd like to make it smoother than that.
Is there any way I could run this without noticing? Any kind of input, even if it extends beyond VBA coding would be very much appreciated!
Private Sub Aut

Application.OnTime Now + TimeValue("00:00:05"), "GenerateTextfile"
End Sub
Sub GenerateTextfile()
Dim FilePath As String
Dim CellData As String
Dim LastCol As Integer
Dim LastRow As Integer
LastCol = 3
LastRow = Blad2.Range("F2").Value
Blad2.Range("A2").Activate
CellData = ""
FilePath = Application.DefaultFilePath & "\MyFile.txt"
Open FilePath For Output As #2
For i = 1 To LastRow
For j = 1 To LastCol
If j = LastCol Then
CellData = CellData + Trim(ActiveCell(i, j).Value)
Else
CellData = CellData + Trim(ActiveCell(i, j).Value) + vbTab
End If
Next j
Write #2, CellData
CellData = ""
Next i
Close #2
End Sub