R
RogerM
I'm having trouble coming to grips with how to parse a multiple line string
of text from a bookmark and am hopeful that someone can provide me with
assistance. I need to capture as string variables two separate text strings
from the first line of text and process those two variables. Then check to
see if the bookmark contains another line of text, and if it does, perform
the parsing and processing routine again. And continue that process until
all the lines in the bookmark have been processed.
I can parse the first line of text in the bookmark with the following code,
and that provides me with the two variables (strAgency and strNumber) that I
need for the next step in the routine.
strKSOR = ActiveDocument.Bookmarks("bKSOR").Range.Text
strAgencyStart = InStr(strKSOR, "<")
strAgencyEnd = InStr(strKSOR, ">")
strNumberStart = InStr(strKSOR, "#")
strNumberEnd = InStr(strKSOR, "!")
strAgency = Mid(strKSOR, strKSORAgencyStart + 1, strKSORAgencyEnd - 1 -
strKSORAgencyStart)
strNumber = Mid(strKSOR, strKSORNumberStart + 1, strKSORNumberEnd - 1 -
strKSORNumberStart)
I'm guessing that maybe the str...Start and str...End variables should be
declared as Integers, rather than strings, but I don't know if that makes a
difference or not. I've tried using vbCrLf as the End of string label for
the first line, but that always produces an error in the procedure.
I could set up the ActiveDocument so that it the bookmark ("bKSOR") contains
a single one row, two column table for each pair of data instead of simply a
line of text for each pair of data. I experimented with that approach but
couldn't figure out how to parse text out of a table at all, let alone
multiple tables within the same bookmark.
Thanks,
Roger
of text from a bookmark and am hopeful that someone can provide me with
assistance. I need to capture as string variables two separate text strings
from the first line of text and process those two variables. Then check to
see if the bookmark contains another line of text, and if it does, perform
the parsing and processing routine again. And continue that process until
all the lines in the bookmark have been processed.
I can parse the first line of text in the bookmark with the following code,
and that provides me with the two variables (strAgency and strNumber) that I
need for the next step in the routine.
strKSOR = ActiveDocument.Bookmarks("bKSOR").Range.Text
strAgencyStart = InStr(strKSOR, "<")
strAgencyEnd = InStr(strKSOR, ">")
strNumberStart = InStr(strKSOR, "#")
strNumberEnd = InStr(strKSOR, "!")
strAgency = Mid(strKSOR, strKSORAgencyStart + 1, strKSORAgencyEnd - 1 -
strKSORAgencyStart)
strNumber = Mid(strKSOR, strKSORNumberStart + 1, strKSORNumberEnd - 1 -
strKSORNumberStart)
I'm guessing that maybe the str...Start and str...End variables should be
declared as Integers, rather than strings, but I don't know if that makes a
difference or not. I've tried using vbCrLf as the End of string label for
the first line, but that always produces an error in the procedure.
I could set up the ActiveDocument so that it the bookmark ("bKSOR") contains
a single one row, two column table for each pair of data instead of simply a
line of text for each pair of data. I experimented with that approach but
couldn't figure out how to parse text out of a table at all, let alone
multiple tables within the same bookmark.
Thanks,
Roger