novice: dsofile.dll -> template path

T

tim moor

dear vba gurus,
i'd like to read the template path of a few hundreds doc's in a directory.
for that reason i created a vba script to access the doc-properties (with
the help of dsofile.dll).
is there a way on how i can access the path and the name of the document
template ?

thank you very much
tim
 
P

Peter

tim moor said:
dear vba gurus,
i'd like to read the template path of a few hundreds doc's in a directory.
for that reason i created a vba script to access the doc-properties (with
the help of dsofile.dll).
is there a way on how i can access the path and the name of the document
template ?

thank you very much
tim

Document.AttachedTemplate will give you the name of the template
Application.Options.DefaultFilePath(wdUserTemplatesPath) will give you where the user templates are stored
Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath) will tell you where the workgroup templates are stored.
Combine the name of the template and the path, then use the Dir command to test for the existence of the template. If it doesn't exist in one place, test for it in the other.
You don't need to use any special dll if you're doing this in VBA or VBScript, just create an instance of Word.Application, and an instance of each document in turn, then query the properties.

hth,

-Peter
 
T

tim.moor

peter,
thank said:
You don't need to use any special dll if you're doing this in VBA or
VBScript, just create an instance of Word.Application, and an instance of
each document in > turn, then query the properties

as i'm quite new to vb i still have a question: there are lots of documents
i have to query. if possible i dont want to open every document just to read
the template-properties. (dsofile.dll allows you to read/change properties
without opening the document). so you propose to create an instance of each
document, can i do this without opening the doc's ??

thank you very much
tim


"Peter" <peterguy -at- hotmail -dot- com> schrieb im Newsbeitrag
tim moor said:
dear vba gurus,
i'd like to read the template path of a few hundreds doc's in a
directory.
for that reason i created a vba script to access the doc-properties (with
the help of dsofile.dll).
is there a way on how i can access the path and the name of the document
template ?

thank you very much
tim

Document.AttachedTemplate will give you the name of the template
Application.Options.DefaultFilePath(wdUserTemplatesPath) will give you where
the user templates are stored
Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath) will tell you
where the workgroup templates are stored.
Combine the name of the template and the path, then use the Dir command to
test for the existence of the template. If it doesn't exist in one place,
test for it in the other.
You don't need to use any special dll if you're doing this in VBA or
VBScript, just create an instance of Word.Application, and an instance of
each document in turn, then query the properties.

hth,

-Peter
 
C

Cindy M -WordMVP-

Hi Tim.moor,
as i'm quite new to vb i still have a question: there are lots of documents
i have to query. if possible i dont want to open every document just to read
the template-properties. (dsofile.dll allows you to read/change properties
without opening the document). so you propose to create an instance of each
document, can i do this without opening the doc's ??
dsofile only reads "document properties", not properties of the document
object. These are two different things. The first is information stored by the
user, in the document's binary file structure. See File/Properties in any
Office application.

The latter are part of the object model and only exist as properties when
automating the document (meaning it does have to be open). The information is
stored in the document, but not as "document properties". Therefore, dsofile
can't read it.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top