473,288 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

Read Multiple files in Vb6

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
3 4829
BSOB
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
Does this code not open word but also Excel?
Jul 16 '06 #3
siddhi
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

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

Similar topics

7
by: Batista, Facundo | last post by:
People: I'm trying to convert my father from using COBOL to Python, :) One difficult thing we stuck into is how to read, from python, files written with COBOL. Do you know a module that...
0
by: Majordomo | last post by:
-- >>>> --36742377 **** Command '--36742377' not recognized. >>>> Content-Type: text/plain; charset=us-ascii **** Command 'content-type:' not recognized. >>>> Content-Transfer-Encoding: 7bit...
4
by: googlinggoogler | last post by:
Hiya, The title says it all really, but im a newbie to python sort of. I can read in files and write files no probs. But what I want to do is read in a couple of files and output them to one...
3
by: Albert Tu | last post by:
Dear there, We have an x-ray CT system. The acquisition computer acquires x-ray projections and outputs multiple data files in binary format (2-byte unsigned integer) such as projection0.raw,...
5
by: JenHu | last post by:
Hi experts, I wrote a function which retrieves a file in the folder, the file path is : Dim sr As New StreamReader(strFilepath & ReturnFileName) What if I have more than 1 file_name in...
5
by: Sumana | last post by:
Hi All, We developed our project on VC++.Net console application to create image of disk and to write the image We are having problem with reading and writing the sector beyond 6GB Disk or...
35
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
8
by: Zephyre | last post by:
I have some UTF-8 text files written in Chinese to be read. Now the only method that I know to read text from it is to use fopen() function. Thus, I must read the contents byte by byte, change the...
8
by: dosworldguy | last post by:
I have been having a very peculiar issue from a long time. I have an application where multiple clients read from a shared set of files. When a record is changed, sometimes the win9x clients...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.