By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,812 Members | 863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,812 IT Pros & Developers. It's quick & easy.

Read Multiple files in Vb6

P: 3
Hi, I am very very new to vb6. I am trying to browse and read multiple microsoft word files. i am able to do for one file as follow, but not multiple files. Please I need help ASAP. Thanks

Private Sub Process()
On Error GoTo Err_Handle
Dim i As Double
Dim SRSWordStr As String
Dim newStart As Double
Dim tmpStrStart As Double
Dim tmpStrEnd As Double
Dim StopFinding As Boolean
Dim OneSRSTagInfo As String
Set SRSWordApp = New Word.Application
Set SRDDWordApp = New Word.Application
SRSWordApp.Documents.Open CStr(txtSRSF)
SRDDWordApp.Documents.Open CStr(txtSRDDF)
CreateExcelFile
SRSWordApp.Selection.WholeStory
SRSWordApp.Selection.Copy
SRDDWordApp.Selection.WholeStory
SRDDWordApp.Selection.Copy
'MsgBox SRSWordApp.Selection.Text
SRSWordStr = SRSWordApp.Selection.Text
SRDDWordStr = SRDDWordApp.Selection.Text
rw = 2
newStart = 1
While StopFinding = False
If newStart = 0 Then
GoTo LBLSAVE_FILES
End If
If InStr(newStart, SRSWordStr, "[") > 0 Then
For i = newStart To Len(SRSWordStr)
If Mid(SRSWordStr, i, 1) = "[" Then
tmpStrStart = i
tmpStrEnd = Val(InStr(i + 1, SRSWordStr, "[") - 1)
If tmpStrEnd = -1 Then
newStart = 0
StopFinding = False
OneSRSTagInfo = Mid(SRSWordStr, tmpStrStart)
Else
newStart = tmpStrEnd + 1
OneSRSTagInfo = Mid(SRSWordStr, tmpStrStart, Val(tmpStrEnd) - Val(tmpStrStart))
End If
TransferToExcel (OneSRSTagInfo)
rw = rw + 1
End If
Next
Else
StopFinding = True
End If
Wend
LBLSAVE_FILES:

Columns("A:D").EntireColumn.AutoFit
xlFile.Range("A1:D" & rw).BorderAround 1
xlFile.ActiveWorkbook.SaveAs txtXl
xlFile.ActiveWorkbook.Close
SRSWordApp.ActiveDocument.Close
SRDDWordApp.ActiveDocument.Close
SRSWordApp.Quit
SRDDWordApp.Quit
xlFile.Quit
Set SRDDWordApp = Nothing
Set SRSSWordApp = Nothing
Set xlFile = Nothing
MsgBox "Processing Complete"
Exit Sub
Err_Handle:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub
Jul 11 '06 #1
Share this Question
Share on Google+
3 Replies


BSOB
P: 77
ok, without taking the time to think (which i find is usualy best in programming) i would say make arrays. take your varaibles and dim them with a (10) on the end like:
dim x(10) as integer
this makes 11 x's to work with (or 11 files). if the code works once, it will work again.
so... for next loop time!

Dim i As Double(4)
Dim SRSWordStr(4) As String
Dim newStart(4) As Double
Dim tmpStrStart(4) As Double
Dim tmpStrEnd(4) As Double
Dim StopFinding(4) As Boolean
Dim OneSRSTagInfo(4) As String
const filesopen = 5
for j = 0 to filesopen-1
'<insert the rest of your code here and at the end of each varable put '(j)'.
next j

'note that i havent understoon your code snipit as there are variables with different scopes like rw that i dont understand there purpose.
'there is the posibility my help has been completely useless. yah...
Jul 15 '06 #2

P: 11
Does this code not open word but also Excel?
Jul 16 '06 #3

P: 3
what it basically does is ...opens word files and get information and put it in excel. I have one file to excel but not multiple files working. I am not sure how would i deal with arrays when I have to set the SRSWordApp As Word.Application.....like..

Dim cellno As String
Dim rw As Double
Dim cChar As String

Dim SRDDWordStr As String
Dim SRSWordApp As Word.Application
Dim SRDDWordApp As Word.Application

Dim xlFile As Excel.Application
Dim ArrayNum As Double
Dim TermArray() As String

after that..i have process method as above. Thanks A Bunch for the replys guys..
Jul 17 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.