Not sure if posted in correct NG, but here goes...
I have a VB proggie that accesses an Access DB and Word documents. The DB
has a table of valid documents it will process in a directory full of word
documents. The word documents themselves have HIDDEN text that the program
searches for to select the range and code for a specific detail. (e.g.:
{SA some description here} )
I was using the FIND feature to hunt for the "{" then find the "}" and
select the range in between in both are found. This was running along
smoothly until I encounter a table with the curly brackets flagged. when it
finds the open bracket I grab the searchrange.start value, then the find
searches for the closing bracket and I grab the searchrange.end value. The
END should obviously be larger than the beginning. However, that is NOT
happening within a table, it works for everything outside the tables. I'm
including the code for your edification, but please note it is in VB6
format.
To put it simply, I'm trying to search a document for all text withing "{" &
"}" and write them to an array for my DB processing.
Thank you so much for your thoughts!
Steve
Here is the code that searches my open word document.
Set searchRANGE = myDOC.Content
Do Until blnDONE = True
If myDOC.ProtectionType <> wdNoProtection Then
For X = 1 To 2
txtINFO(X) = "Protected"
Next X
Exit Do
End If
myDOC.Content.Find.Execute "{", Forward:=True
searchRANGE.Find.Execute "{", Forward:=True
If searchRANGE.Find.Found = True Then
intSTART = searchRANGE.Start
Set endRANGE = myDOC.Range(searchRANGE.Start)
endRANGE.Find.Execute "}", Forward:=True
If endRANGE.Find.Found = True Then
If endRANGE.End > intSTART Then
intEND = endRANGE.End
Set rngINFO = myDOC.Range(Start:=intSTART, End:=intEND)
cnt = cnt + 2
ReDim Preserve txtINFO(1 To cnt)
txtINFO(cnt - 1) = CleanUP(Mid(rngINFO.Text, 2, 2))
Dim txtOLD As String: txtOLD = txtINFO(cnt - 1)
txtINFO(cnt) = CleanUP(Mid(rngINFO.Text, 4,
Len(rngINFO.Text) - 4))
Call VerifyAbbrev(txtINFO(cnt - 1), txtINFO(cnt),
rsABBREV)
If txtOLD <> txtINFO(cnt - 1) Then
rngINFO.Characters.Item(2).InsertAfter
Right(txtINFO(cnt - 1), 1)
End If
End If
Else
blnDONE = True
End If
Else
blnDONE = True
End If
Loop
Klaus Linke - 18 Dec 2006 22:18 GMT
Hi,
Might be easier to match the whole brace with a wildcard search for \{*\},
or (safer) something like \{[!^13]@\}
Your code looks a bit weird to me...
myDOC.Content.Find.Execute does not seem to have any purpose,
Set endRANGE = myDOC.Range(searchRANGE.Start)
should probably read
Set endRANGE = myDOC.Range(searchRANGE.Start, searchRANGE.Start)
Regards,
Klaus
> Not sure if posted in correct NG, but here goes...
>
[quoted text clipped - 64 lines]
> End If
> Loop