Jay - that was *really* useful - thanks.
Jay Freedman said:
Because you're passing your text through the Windows clipboard, you
could have a timing problem, especially if the documents and/or the
bits of text inside the bookmarks are fairly large.
I had *assumed* that copy would not return until it had completed... the
document *is* karge (>750pp, ~6000 comments, ~19MB), and some of the
bookmarks are large (18,000 words excluding associated comments and other
text in adjacent columns) although the 1st bookmark on ~p3 which also fails
is small ~240 words in a 10 row, 5 column table). A timing problem makes a
great deal of sense.
The following snippet does the same thing as the code you showed, but
without all the overhead (and with some considerable streamlining in
other areas as well):
"Considerable streamlining" LOL! My bricks respond to gravity perfectly well
thank you <g> [I'm supposed to be writing, not coding <g>, the supporting
extensions to word I have written for commenting functionality, in-table
outlining, journalling and other stuff do run to several thousand lines...
and yes, I know it shouldn't all be in normal.dot but...]
However, back the problem and potential solution. I tried your code and
found a couple of problems
1/ I said that the bookmarks span a column, but didn't make it clear that
there are several columns... the range based FormattedText assignment takes
all text between the bookmark ends not just that in the bookmarked column...
which I think is why I did a select/copy/paste - bookmark ranges in tables
mark table spanning end-endranges, but when selected, the range corresponds
to the visually inspired expectation (i.e. that a bookmark in one column
contains only what is in that column....)
2a The ComputerStatistics on the result completely kills Word (Word
2002)... seen from the VBE it just locked up, trying again and looking at
Word and manually Ctrl-A selecting all the text that had appeared, I chose
Tools...Word Count and after coming up with a count (incorrect, BTW) Word
then attempted repagination and hung. The only suggestion I had for that was
perhaps the presence of Unicode characters carried across from Col 1...
2b/ When I tried to test that hypothesis Word locked up on the
FormattedText assignment, eating 50% of CPU time. I need to give it more
thought and test data other than the real data... why it worked (as far as
the range assignment) once and never since I have no idea either...
NB Col 1 of my table provides "outlining" capabilities with Unicode block
triangles pointing right and down to indicate collapsed/expanded rows; Cols
3 & 4 are never both "visible" - either one or the other is set to a very
small width and hidden text, and Col 4 may contain embedded images; Col 5
contains the text of interest with maybe 1-50+ potentially
overlapping/intersecting (in scope) comments, which may contain hyperlinks
(and possibly other stuff)
I think it might be easier/quicker just to try getting data from the
clipboard through another object and waiting until that is successful before
doing a paste - if it is a timing issue that approach could confirm and
resolve at the same time... 'tis such things that lead to the atrophy of
elegance...
Or is there some other way to avoid such timing issues - can one make VBA
code sync rather than async?
Very grateful for your input though
Julian
--