Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Probs inserting data at a bookmark
Message
From
09/01/2019 21:10:49
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
09/01/2019 14:55:07
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012 R2
Network:
Windows Server 2012 R2
Database:
Visual FoxPro
Application:
Desktop
Virtual environment:
VMWare
Miscellaneous
Thread ID:
01665236
Message ID:
01665250
Views:
53
>Hi all,
>
>Customer has a LOT of templates where from data in the database into a Word template. I have used two techniques - one uses a bookmark to indicate the location to insert the data and have also used merge fields to insert the data. A fair bit of the overall coding was done in 2008 based on the Office Automation book by Tamar and Della Martin. Overall the customer is really happy and it is heavily used to this day.
>
>But users experience occasional problems with the process (a few times a month, various users). I use a TRY/CATCH so they don't get an outright crash and I just throw up a dialog for them to try again. In the past I have just told them that it is due to "general Word flakiness" (which might be true) which is what I have thought and so I did not log the error in detail anywhere. Recently I decided to log the error to try to track this down.
>
>Here is the general process (abbreviated, most error trapping removed):
>
>
>
>* get a reference to the bookmark
>
>loBookmark = THIS.GetBookmark(lcBookmarkName,toDocument)  && method of class that error traps etc
>
>* grab the range object for the bookmark
>
>loRange = loBookmark.Range
>
>* insert the data (lxBookmarkdata initialized previously)
>
>loRange.InsertAfter(lxBookmarkData)
>
>
>
>Now that I am logging it, here is the error information:
>
>OLE IDispatch exception code 0 from Microsoft Word: This method or property is not available because this command is not available for reading...
>
>AERROR() contents:
>Cell 1: 1429
>Cell 2: CMD1.
>Cell 3: This method or property is not available because this command is not available for reading.
>Cell 4: Microsoft Word
>Cell 5: wdmain11.chm
>Cell 6: 37373
>Cell 7: 4605
>
>How can I get more details on this error - the wdmain11.chm file does not exist anywhere (that I could find) so I can't look up the details (if they even exist in the .chm file).
>
>Any other way to get more information back from OLE that I could maybe capture after the error?
>
>Albert
>
>
>
>Bear in mind that this process is probably fired a few thousand times a month and I usually get a couple emails a week or less). Templates have not changed before or after.

And, all this code is wrapped with a if Bookmarks.Exists ? If not, try adding it. You wouldn't be able to read a non-existent bookmark's range.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform