>
loBookmark = .GetBookmark(lcBookmarkName,toDocument)
>
>That method handles cases of no bookmarks in the document or the specified bookmark not being found (mispelled or removed from the template etc). It returns an object reference or null. So my calling code just has to check for null.
>
>
>IF NOT ISNULL(loBookmark)
>
> * get the range object for the bookmark
> loRange = loBookmark.Range
>
> * and then insert the data using the ranges .InsertAfter() method:
> loRange.InsertAfter(lxBookmarkdata)
>
>
>and so I see occasional errors on this last line; in this case it was error 1429 with the message "OLE IDispatch exception code 0 from Microsoft Word: This method or property is not available because this command is not available for reading..."
>
>But why does this happen? I have checked and/or trapped that I have a bookmark object before this happens but I still get an error probably about once every 100-500 runs of this code. Of course the above code does not trap if the range object is somehow not correct - but that should exist if the bookmark exists.
>
>Any thoughts on the above?
Beats me. I was experiencing such things for years. Things that work hundreds of times a day would suddenly become "unavailable" or "does not exist", "not found" etc for a few cases in a batch, while working fine for the rest of the batch. Why? Because I was trying to use automation.
Solution? Avoid it.