dcsimg
Results 1 to 5 of 5

Thread: Attached Template

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2017
    Posts
    12

    Attached Template

    żIs possible to know, what's the attached template in a *.doc, without open the file?
    thanks

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,500

    Re: Attached Template

    i don't think there's a reference to a maybe used *.dot inside a *.doc
    http://www.fileformat.info/format/msword/corion.htm
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2017
    Posts
    12

    Re: Attached Template

    I don't know if it is an something undocumented, but yes docs, have his AttachedTemplate.
    You can try in VB6:
    Code:
        Dim oWord As Word.Application
        Dim oDoc As Word.Document
        
        Set oWord = New Word.Application
        Set oDoc = oWord.Documents.Add("c:\Documents\MyDocument.doc")
        Debug.Print oDoc.AttachedTemplate.FullName
        oDoc.Close
        oWord.Quit
    So you must have change the document to open.
    If you don't have VB6 you can create a template, next a create a document based in this template an open the Visual Basic Editor.
    As you can see in the attached image, you have a reference to the template, an you can run the macro:
    Code:
    Sub MyMacro()
        Debug.Print ActiveDocument.AttachedTemplate.FullName
    End Sub
    Name:  Template.jpg
Views: 15
Size:  18.9 KB
    But to know this, I have to open the document.
    I don't think that the dot is really included in the doc, but, when you open the doc, you open the dot too.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,819

    Re: Attached Template

    but, when you open the doc, you open the dot too.
    not sure about that as if the file is moved to some other computer the template may not be available to open, but it will still show in the vba editor
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2017
    Posts
    12

    Re: Attached Template

    Quote Originally Posted by westconn1 View Post
    not sure about that as if the file is moved to some other computer the template may not be available to open, but it will still show in the vba editor
    First, I working with *.doc, not *.docx, with *.docx, don't know if the behavior is the same, but with *.doc, if I open the document with the template in the original place and run the macro, the result is:
    Name:  NotMoved.jpg
Views: 16
Size:  17.4 KB
    As you can see, the template is in the explorer and the macro indicates the original template.
    If I move, or delete the original template:
    Name:  Moved.jpg
Views: 16
Size:  21.2 KB
    Now the original template isn't show in the explorer and the macro indicates the normal.dot

    Edit:
    I was working with Word XP, with Word 2013, the behavior is similar, the explorer show the reference to the original template, but the macro indicates the normal.dot
    Last edited by gilman; Oct 26th, 2018 at 06:57 AM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width