Results 1 to 10 of 10
  1. #1
    Star Lounger
    Join Date
    Aug 2001
    Location
    Hampshire, England
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    listing docs & their templates (WD97 SR2 )

    ...Well any version really.
    Is there a way to say "for a given folder x, list me all the word docs within it, and state the path and name of their attached template"?
    I would imagine hooking into the file open dialog to get the folder, and creating a new document for the result, but how to do the important bit?
    (Reason: some of our templates have suddenly been playing up: I think I've fixed them, but we want to test some documents that used those templates. But since all are fairly similar, we don't want to have to keep opening documents and looking at Tools>Templates & Addins>Attached template)

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: listing docs & their templates (WD97 SR2 )

    Yes, you can do this with VBA code. Are you up to the task of learning some VBA?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Star Lounger
    Join Date
    Aug 2001
    Location
    Hampshire, England
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: listing docs & their templates (WD97 SR2 )

    Well, let's give it a go - I've dabbled already, but it's been mostly within-the-active-document sort of stuff so far (adding/retrieving boilerplate text, reformatting tables, etc.)

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    185
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: listing docs & their templates (WD97 SR2 )

    I think I might be interested in this, too, so I'm just adding myself to this thread to say thanks in advance...it might help me resolve a different sort of issue. So, thanks in advance!

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: listing docs & their templates (WD97 SR2 )

    Ok, ya all. Hang in there till I get the code written (or somebody beats me to it -- which they will knowing the smart folks around here).
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: listing docs & their templates (WD97 SR2 )

    Pending return of Kevin or the arrival of the smart folk, the following partial solution might get you started. It require the use of a file from Microsoft which allows VB/VBA to read file properties of MSOffice documents. DSOFile can be downloaded from
    <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=xl&Number=40236&Search= true&Forum=xl&Words=dso&Match=And&Searchpage=0&Lim it=25&Old=allposts&Main=39959>here</A>. Once you download and install it, you need to set a reference to it in VB or VBA. The following code will insert a list of word files from a given directory, together with the template name, but not the template path. <pre>Sub ListDocs()
    Dim oFso
    Dim oFldr
    Dim oFile
    Dim dsoDPR As New DSOleFile.PropertyReader
    Dim fApp As Variant
    Dim strTemplate As String
    Set oFso = CreateObject("Scripting.FileSystemObject")
    Set oFldr = oFso.GetFolder("C:My Documents")
    Set dsoDPR = DSOleFile.PropertyReader
    For Each oFile In oFldr.Files
    fApp = ""
    strTemplate = ""
    On Error Resume Next
    fApp = dsoDPR.GetDocumentProperties(oFile).AppName
    On Error GoTo 0
    If Left(fApp, 14) = "Microsoft Word" Then
    strTemplate = dsoDPR.GetDocumentProperties(oFile).Template
    Selection.TypeText Text:=oFile.Name & vbTab & strTemplate & vbCrLf
    End If
    Next
    End Sub</pre>

    There is code <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=vb&Number=28049&Search= true&Forum=All_Forums&Words=getdirectory&Match=Ent ire>here </A> to browse for a folder, which might assist your project.

    Andrew C

  7. #7
    Star Lounger
    Join Date
    Aug 2001
    Location
    Hampshire, England
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: listing docs & their templates (WD97 SR2 )

    Sorry all for the delay in responding: I was, er.. offline Friday... Will get the DSOFile and try Andrew's code as soon as I get the opportunity: and I'm still listening if Kevin or anybody else wants to continue with suggestions!

  8. #8
    Star Lounger
    Join Date
    Aug 2001
    Location
    Hampshire, England
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: listing docs & their templates (WD97 SR2 )

    Okay, I've got the DSOFile dll, Andrew's code (works nicely, though it's way off at the far edges of me understanding what's going on <img src=/S/confused.gif border=0 alt=confused width=15 height=20>) and the folder-browsing code (also works): now what do I put where in order to call one from the other so I can browse and get the doc+template names after I hit OK ?
    (polite answers only please!!)

  9. #9
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: listing docs & their templates (WD97 SR2 )

    In the code posted above (Post No 98687) if you change the line <pre> Set oFldr = oFso.GetFolder("C:My Documents")</pre>

    to<pre> Set oFldr = oFso.GetFolder(getdirectory)</pre>

    you should have the browse routine called so that you can select the folder to process. This assumes that you copied the BrowseforFolders code verbatim.

    Hope it works for you.

    Andrew

  10. #10
    Star Lounger
    Join Date
    Aug 2001
    Location
    Hampshire, England
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: listing docs & their templates (WD97 SR2 )

    Yup, works nicely. Thanks for your help <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •