Thanks Jonathan for the reply. However, please excuse my muddle-headed
thinking and I realise you're giving me a clue to follow but I've lost the
plot here...
At present I've got this:
> Thanks Jonathan for the reply. However, please excuse my muddle-headed
> thinking and I realise you're giving me a clue to follow but I've lost the
[quoted text clipped - 4 lines]
> ...whick looks at the attached template and sucks out the value of the
> "Department" CDP.
No it doesn't. When you create a new document based on the template, it
contains a copy of the template's document properties. This line of code
reads the "department" property of the document itself
> What I want to do is find the key word which I can put where
> "activedocument" is in the example above and pick out a value from cdp's
> in the Global Template which I can see is loaded. I've tried, even, hard
> coding the global template's file name where "activeDocument" is written
> but to no avail.
Like I said, use ThisDocument instead
txtdepartment=ThisDocument.customdocumentproperties("department").value
This will pull the "department" property out of the add-in that contains the
currently running code. It really is that simple.
> Even though the Global template is loaded does it have to be attached to
> the active document prior to accessing the CDPs of that template? Or is
> "loaded" considered to be also "attached"?
The attached template is the template on which the document is based. There
can only be one attached template at a time for a document. You can have as
many loaded add-ins as you want. The ThisDocument object refers to the
template or add-in which contains the code that you are running at the
moment.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
Lynne O'Regan - 18 Mar 2005 17:07 GMT
Again, thanks Jonathan.
Regrettably, I must report that it doesn't work in my case.
Let me just summarise - more for my own benefit, I suppopse...
I have a template called MyLetter.dot
Inside that template there is a user form called frmMyForm which has a
textfield called txtMyDepartment
There is also the global template called myGlobalTemplate.dot which is
loaded.
Inside that global template is a custom document property called
"department". That property has a text value of "Human Resources"
When I create a document based on MyLetter.dot and the UserForm appears
containing the texfield txtMyDepartment I want the a VBA to run off and read
the value of the "department" CDP and place it into my textfield.
Based on your guidance, Jonathan, I've written the following:
txtMyDepartment = ThisDocument.CustomDocumentProperties("department").Value.
By the way, is not the code that is running situated within MyLetter.dot?
The error message I get is this:
"Could not set the Value Property. Invalid property value."
Thanks again.
Lynne
>> Thanks Jonathan for the reply. However, please excuse my muddle-headed
>> thinking and I realise you're giving me a clue to follow but I've lost
[quoted text clipped - 31 lines]
> the template or add-in which contains the code that you are running at the
> moment.
Jonathan West - 18 Mar 2005 21:43 GMT
You didn't make it clear that your code was in the attached template, not in
the add-in.
I don't think you can retrieve properties from a template loaded as an
add-in from a macro outside te add-in.
If all you want is a general storage for a few settings, I would recommend
you use the registry instead, and use GetSettings and SaveSetting to save
and retrieve them.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
> Again, thanks Jonathan.
>
[quoted text clipped - 65 lines]
>> to the template or add-in which contains the code that you are running at
>> the moment.
David Sisson - 18 Mar 2005 22:16 GMT
Would it be feasible to add a listbox and let the user choose their
dept? Then based on the user's choice, you can populate the userform
with proper info.
Lynne O'Regan - 19 Mar 2005 00:01 GMT
I could have David - done it many times before. Just was trying to be clever
I suppose and use the add-in template as a place to hold default values.
Clients I'm creating this for don't want anything written to the registry.
This last method being a possible alternative as Jonathan suggested. Pity,
actually, as that might have been the better idea.
Regards
Lynne
> Would it be feasible to add a listbox and let the user choose their
> dept? Then based on the user's choice, you can populate the userform
> with proper info.
Jean-Guy Marcil - 19 Mar 2005 07:03 GMT
Lynne O'Regan was telling us:
Lynne O'Regan nous racontait que :
> I could have David - done it many times before. Just was trying to be
> clever I suppose and use the add-in template as a place to hold
> default values. Clients I'm creating this for don't want anything
> written to the registry. This last method being a possible
> alternative as Jonathan suggested. Pity, actually, as that might have
> been the better idea.
You can use an *.ini file instead of the registry...

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