Can somebody let me know how in Word doc can a word be searched and then get Nth word in that line(found text line), using VB??

Recommended Answers

All 3 Replies

Ive had a similar problem to sort out. First get yourself a RAW TEXT notepad type program, I use Textpad, it shows ALL characters, including the ones under CHR(32). This will give you a general text space layout and some idea on what to search for and where.

Doc files contain loads of data per file to cope with tables, margins, fonts etc. Once you have looked at a few test documents youll have an idea what to look for.

After that its just a case of INSTR search for what you want and scan the SPACES back to the start of the line. Do it on a line scan principal and it doesnt get confusing.

Diguelo,
Can you make your reply more clear.
I dont get a clear picture on how to search for a string in Notepad. Ideally i too have to view the data(tab seperated logged values) in notepad as they are around 80 different parameter values logged per sec(80 col per row). I need to search for a state( string) and then look for some parameters in that row(of that time stamp). when i try to open this text file in MS Word, each row(with 80 col) gets split across 6 lines. How do i do this with notepad/csv?

I wouldnt bother with comma seperated values type data handling as the commas may need to be sent in your datastream as part of a block.

I meant to have said if you use a notepad type program to first analyse your document to get your program scanning correct as in make a test document and see what does what to a rich text environment document. As in make a doc file, open it in notepad or similar and see what is actually in it and how changes affect data positions within the file.

Once you have a full idea on whats going on then all you need do is if say the first 100 characters of a doc file are for the tab table, font list etc then you can either skip them or search for the details.

Once you have an idea where to look in the file for what your after then its relatively easy to use a search string and Instr system to get out all relevant information.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.