Access.2007.VBA.Bibl..

(John Hannent) #1
.Open
.LoadFromFile strTextFile
.Position = 0
strData = .ReadText(adReadAll)
End With

Close Stream object.


stm.Close

Case 2

FSO


Set fso = CreateObject(“Scripting.FileSystemObject”)
Set txt = fso.OpenTextFile(FileName:=strTextFile, _
IOMode:=ForReading)

Read all data from file.


strData = txt.ReadAll

Close file.


txt.Close

Case 3

VB


Open text file for reading data.


Open strTextFile For Input As #2
Do While Not EOF(2)

Save data from a line in the text file to a variable.


Input #2, strLine
strData = strData & IIf(strData <> “”, _
vbCrLf, “”) & strLine
Loop

Close file.


Close #2

End Select

Working with Files and Folders 9

Free download pdf