Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Handling errrors in automation better
Message
From
22/05/2019 01:55:26
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
21/05/2019 15:02:14
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01668779
Message ID:
01668795
Views:
55
>
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)    && lxBookmarkdata = data worked up in form
>
>
>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.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform