The code below creates a excel file with column headers and writes data to the columns. If you have VPN access to the text file on the internet you can open the file as a normal text file.
` --------------- Read Data From File
Dim sData as String
Dim FileNum as Integer
Dim FileName as String
FileNum = FreeFile
FileName = "X:\Sample.TXT"
Open FileName For Input As FileNum
While Not EOF(FileNum)
Line Input #FileNum,sData
Wend
Close #FileNum
You need to Reference Microsoft ActiveX Data Object Libary
Put a Button on the form
Private Sub Command1_Click()
Dim i As Integer
Dim strConn As String
Dim FileName As String
' Excel file name to create
FileName = "c:\Book1.xls"
'Open the ADO connection to the Excel workbook
Dim oConn As ADODB.Connection
Set oConn = New ADODB.Connection
strConn = "Provider=Microsoft.Jet.OL
strConn = strConn & "Extended Properties=""Excel 8.0;HDR=NO;"""
oConn.Open strConn
' Create a new table (or worksheet in the workbook)
oConn.Execute "create table Products (Product char(255), UnitPrice int, UnitsInStock int)"
Dim oRS As ADODB.Recordset
Set oRS = New ADODB.Recordset
oRS.Open "Select * from Products", oConn, adOpenKeyset, adLockOptimistic
' ------- Add sample records to Products workbook
For i = 1 To 25
oRS.AddNew
oRS.Fields(0) = "Item " & i
oRS.Fields(1) = i + 1
oRS.Fields(2) = i + 2
oRS.Update
Next i
oRS.Close
oConn.Close
Set oRS = Nothing
Set oConn = Nothing
End Sub
Main Topics
Browse All Topics





by: egl1044Posted on 2009-10-09 at 03:16:43ID: 25533567
Do you know if the file is large or does the online file just contain a single string of characters?