Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File Format (Word XP)

    Hi. I need help again.

    I am receiving "documents" from other departments that are (as far as I can tell) not actually in Word's DOC format, but are more likely templates saved with a DOC extension. I'm basing this on the fact that 1) a third party application (Reference Manager) throws an error when using those files, saying "No document is open"; and 2) no template is listed in the Document Template property. Also, certain menu options are disabled (such as Save As) even after I use the Immediate window to force a save in true DOC format.

    I would like to be able to more easily determine, via code, what file-format a "document" is using. Is there a property or attribute that would allow me to determine this, even when a document has been given a bogus extension?

    Also, from an academic and technical perspective, what is the difference between Word's DOC and DOT formats? The line must be blurry, since both can contain code modules; yet, as with Reference Manager, the formats must be different somehow.
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File Format (Word XP)

    There is a subtle difference - a template can contain AutoText entries, a document can't, and this is independent of the extension.
    As far as I know, there is no "IsTemplate" property in the Word object model, but it is relatively easy to write code that determines whether the active document is a template:

    Public Function IsTemplate() As Boolean
    IsTemplate = (ActiveDocument.AttachedTemplate = ActiveDocument.Name)
    End Sub

    or

    Public Function IsTemplate() As Boolean
    With Application.Dialogs(wdDialogFileSaveAs)
    .Execute
    IsTemplate = (.Format = 1)
    End With
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Format (Word XP)

    Once again, Hans, thank you for sharing your seemingly infinite knowledge!
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  4. #4
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Format (Word XP)

    There is a property ActiveDocument.Type that describes what kind of document it is. It returns one of three possible DocumentTypes:
    0 wdTypeDocument
    1 wdTypeTemplate
    2 wdTypeFrameset
    So you could test if the document in reality is a template using If ActiveDocument.Type = wdTypeTemplate Then...

Posting Permissions

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