Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Definition of 'ThisDocument'

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
elle0612 - 26 Aug 2006 12:02 GMT
Hi

Can anyone define what object the 'ThisDocument' is in the VBA editor screen?

In my case - my Word 2000 vba project is a template so is the 'ThisDocument'
object mentioned, the page that fronts the template and  belongs with the
template?

If I am correct in my guess, can you open and close 'ThisDocument' as your
ActiveDocument, just like opening a document from another file to include it
as part of your project?

If correct what code would open and close 'ThisDocument' as ActiveDocument?

If I am wrong on all counts, just a simple definition of what 'ThisDocument'
is would suffice.

Thanks
Jean-Guy Marcil - 26 Aug 2006 15:47 GMT
elle0612 was telling us:
elle0612 nous racontait que :

> Hi
>
[quoted text clipped - 14 lines]
> If I am wrong on all counts, just a simple definition of what
> 'ThisDocument' is would suffice.

ThisDocument is a class module that refers to the code container,

So, for example, let's say you have code in a template (*.dot) that
manipulates Document Variables.
Now you create a document based on that template.
Suppose you have this code :

   ActiveDocument.Variable("Test").Value  = "MyName"
   ThisDocument.Variable("Test").Value  = "MyName"

The first line will update (or create it if it does not exist) a variable
called Test in the currently active document (or the document created from
the template that contains the code).
The second line will update the variable in the template itself, not the
document.

So,  when you use ThisDocument in the code, you are referring to the code
container, usually the template used to create the currently active
document.

Since a template is not really "opened" when you create a document, you
cannot open/close it in the normal sense. It is available because it is
attached to a document and is loaded. If you modify it (as in my example
above) you will have to save the changes unless you want them discarded.
You could actually open it is well, but this is very rarely necessary.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.