View Single Post
 
Old 10-09-2023, 12:36 PM
Donovahkiin Donovahkiin is offline Windows 10 Office 2016
Novice
 
Join Date: Oct 2023
Posts: 4
Donovahkiin is on a distinguished road
Question Help with a complicated search macro

Hello! I do transcription work where I write long documents with long question/answer segments. The bulk of it is written in a Q&A Style made for these documents, where attorney and witness talk back and forth. Sometimes an interruption happens which is written using the Colloquy Style format, until it later returns to questioning. So for example, it might look like the following.
Code:
Q   Good morning, Mr. Doe. 
A   Good morning. 
Q   When did -- hold on.  I'm getting ahead of myself. 
    Would you please state your full name for the record?    
A   John Doe.
Q   When did you hurt your left leg? 
         MR. ATTORNEY:  Objection.  Vague.
I'm trying to write a macro that will highlight if there's any times that on consecutive lines I lead it with the wrong speaker token. Meaning, if I have a Q line followed by another Q line or an A line followed by another A line. Each line leads with either Q or A followed by the tab key. The objection doesn't use any tab characters, it just changes to the Colloquy style.

I've been able to use .Find code blocks to search and replace other things, and I can successfully find a line using .Text = "Q" & Chr(9), but I don't know how to extend it for conditional checks like this. If I were to write out my goals in pseudocode, it would be something along these lines.

Code:
*  Search for "Q tab"
*  Search for the next newline character, Chr(10)
*  Is first character in the next line "Q tab" again? 
  - if so, HIGHLIGHT IT. 
  - if it's not, AND it's not "A tab", AND it's still in Q&A style, 
    - search for the next newline character again and repeat. (accounts for multiple paragraphs within a single Q or A)
  - else, we're done here.  We found that this "Q tab" is followed by an "A tab".
*  Continue for the rest of the document.
Then I would duplicate and mirror this macro to make another one that checks if there's two A lines in a row.

Any help I could get towards this would be massively appreciated!
Reply With Quote