Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Work with only one Instance of Word
Message
De
28/05/2002 09:21:31
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00658782
Message ID:
00661962
Vues:
27
>I'm not sure what you mean by store a reference to Word using a Property of my form.

If I have a form that needs access to Word, I add a custom property to the form, oWord, and the first time I need to use Word, I instantiate it and save the reference in the oWord property:

This.oWord = CreateObject("Word.Application")

If, instead, I need Word throughout an application, I add the property to the application object, and use similar code to instantiate it.

> IF VARTYPE(oWord) <> "O"
> RELEASE oWord
> PUBLIC oWord
> oWord = CREATEOBJECT("Word.Application")
> ENDIF

I know that a lot of the examples in the book use a structure like this, but as we explain near the beginning, that's to enable readers to run the examples, and then examine the results. In real applications, neither Della nor I use a public variable to hold the object reference to a server.

>I think I am going to rethink to code above, as I have skipped ahead in your book and started reading Chapter 15 "Wrapping Up The Servers". I think I will incoporate those classes into my application.

That chapter should help. It addresses the question of checking whether you have a reference already.

Do be sure to go to www.hentzenwerke.com and get the updates to those classes. There are a few mistakes in the printed version.


>And pardon me if my question on the "servers already running outside the application" is answered in there. I guess I hadn't got to that part yet.

I'm not sure we addressed that question in the book. In general, I wouldn't connect to an instance of the server that a user has started outside my application (except in special circumstances). That's the user's copy. If my application needs a server, I instantiate it.

Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform