Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Dim sFileName As String 'Name of files within the folder will be stored

Dim i As Integer 'This will count the files read***


Dim wrd As Word.Application
Dim wrdCount As Long 'Number of characters within the file
'Get the first file with extension "DOC" ***
sFileName = Dir$("C:\Virology\*.DOC") '***
Do While sFileName <> "" '***
Set wrd = New Word.Application 'Create obj of word application
wrd.Visible = False
wrd.Documents.Open "C:\Virology\" & sFileName
wrdCount = wrd.Documents(1).Characters.Count
Text1.Text = Text1.Text & vbCrLf & i & wrd.Documents(1).Range(0,
wrdCount).Text
wrd.Documents(1).Close
Set wrd = Nothing
sFileName = Dir$ '***
i = i + 1
Loop

================================================================
Dim sFileName As String
'Get the first file with extension "DOC"
sFileName = Dir$("C:\MyFoldername\*.DOC") ' You can change it suit ur
needs
Do While sFileName <> ""
'Your code for opening the file and getting text should go here
sFileName = Dir$
Loop

You might also like