Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Better method to insert data into Word
Message
De
12/09/2019 12:27:52
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
12/09/2019 10:35:55
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01670760
Message ID:
01670791
Vues:
54
>Hi Cetin,
>
>>To my experience, there is not a problem with using bookmarks or document variables or merge fields.
>>It is however a problem if you are instantiating word using getobject() instead of creatobject().
>
>I first attempt a getobject() and if that does not return anything, I do a createobject(). I coded this about 10 years ago and I think I did that because, if I remember, there is a fair bit of bloat on the users machine if you create a new instance every time - can't find a note to confirm this but I think that was the reason I did this.

OK, then that explains the errors. Stop using GetObjects() and your problems should end (use a local variable for the word object and be sure it is released as soon as it is used).


>
>>My favorite is mergefields. You simply set the data and do the merge to a destination. Bookmarks work quite nicely too, provided you check existence of bookmark before attempting to set it. But it is for a single document (mailmerge can output N documents from a single template in a single shot). >Same with document variables.
>
>>PS: I wonder what reasons might be given against mergefields.
>
>Re-reading the chapter in the book, the only reason "against" mergefields is the fact that you have to have ODBC set up on the client machine to attach to a data source - and the potential problems with that. They then recommend to instead create the datasource on the fly via setting up a table in a new document (if I follow them correctly) and then programatically attaching that data to the main document. Or at least it seems that way. The code in their book seems fairly straightforward.

" you have to have ODBC set up on the client machine to attach to a data source" I would disagree. I posted here a few times I believe, mailmerge samples, not using ODBC but VFPOLEDB. Even if, suppose you can't directly connect to VFP data, you can simply create a txt file as a 'data source', or directly write to a mailmerge documents' data document.


>
>But my main thought is on getobject() vs. createobject() - have you seen a consistent problem with this and if so, if I switched to always using createobject(), what are the implications to doing that? (I already have a parameter in my class to tlUseExistingServer, which i know always pass as .T. so it would be easy for me to stop doing that).
>
>Thanks a lot.
>Albert

Yes, getObject() is problematic and I have been telling that I am against it since years (many posts here saying GetObject() should not be used).
Ç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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform