Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Reading

Status
Not open for further replies.

newbie1983

Programmer
Sep 9, 2003
52
GB
I am reading from a text file straight into an OLE excelsheet which is on a visual basic form. The code below is what ive written so far :

Private WithEvents myExcel As Excel.Workbook
Private WithEvents mySheet As Excel.Worksheet

Public Sub Form_Load()

Dim File As TextStream
Dim DatafromFile As String
Dim ofso As New FileSystemObject
Dim ofile As File
Dim i As Integer


Set myExcel = OLE1.object

myExcel.Activate
Set mySheet = myExcel.ActiveSheet


Set File = ofso_OpenTextFile("I:\laceResults.txt")
For i = 1 To 3
DatafromFile = File.ReadLine
mySheet.Cells(1, 0) = Right(DatafromFile, 7)
Next i
File.Close

End Sub


It doesnt seem to like the statement :
mySheet.Cells(1, 0) = Right(DatafromFile, 7)

Any ideas?

Kind Regards
Hinesh
 
Cells(x,y) is 1-based, i.e. there is no column 0. Columns start at 1


Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"A computer program does what you tell it to do, not what you want it to do." -- Greer's Third Law
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top