Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Feb 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Doc Version or Format (MS Word 97 or higher)

    Using VBA

    I do not want to know what version of Word is on the machine...I want to know if the document (document object) that I am looking at is a Word 95 (*.doc) or some other type. That is, how do I find out if the document was saved as a Word 200 (*.doc), Word 95 (*.doc), or other versions? Most of these files will
    have a doc extension but I need to see if it is Word 2000 or earlier.

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Word Doc Version or Format (MS Word 97 or higher)

    Do a <pre>MsgBox ActiveDocument.BuiltInDocumentProperties("Applicat ion name").Value</pre>

    on several of your documents and see if that does it. Only have XL2K here and it gives "Microsoft Word 9.0". This probably is just the current application, hope not!
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Word Doc Version or Format (MS Word 97 or higher)

    Well, all of the DocumentProperties appear to be useless: must get overwritten during Open. Might try looking during the document open event.

    Application.Dialogs(wdDialogFileSaveAs).Format gives you a little information but not much. I was at least able to identify an RTF file.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Word Doc Version or Format (MS Word 97 or higher)

    Hopefully here is some real help. First look if the .Format is equal to any of the wdSaveFormat constants, if not, use something like the following: <pre>Sub DisplayDocFormat()
    Dim fcConv As FileConverter
    With Application.Dialogs(wdDialogFileSaveAs)
    For Each fcConv In FileConverters
    If fcConv.CanSave Then
    If fcConv.SaveFormat = .Format Then
    MsgBox "Format is " & .Format & ", " & fcConv.FormatName
    End If
    End If
    Next fcConv
    End With
    End Sub</pre>


    This at least catches Word Perfect and WordPad documents, but I don't see any way of knowing if it is Word 97. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word Doc Version or Format (MS Word 97 or higher)

    I couldn't find a property that in one step determines the version of Word that the individual compatibility settings mimics. Bummer.

    This is not easy to access programmatically, but if you open the file with the Recover Text From Any File filter, you will find, toward the end, an indication of the format. I haven't quite figured out the pattern; many documents say "Word.Document.8", many contain MSWordDoc as well, the ones I know I created from scratch in Word 2000 indicate Microsoft Word 9.0 (as well as one or both of the above), unfortunately, so do old documents I cleaned up and in which I changed the compatibility setting to Word 2000.

  6. #6
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Word Doc Version or Format (MS Word 97 or higher)

    Well, duh, it's right in the DocProperties Application name, but we just cannot open it with Word, because it updates that property. Fortunately, Microsoft has provided a free downloadable tool to do this. It's called dsofile and there is a good description on the Word MVP site, <A target="_blank" HREF=http://www.mvps.org/word/FAQs/MacrosVBA/DSOFile.htm>here</A>.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  7. #7
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Word Doc Version or Format (MS Word 97 or higher)

    Eureka, hopefully one last post. After installing DsoFile, in the VBE use Tools | References to add a reference to "DS: OLE Document Properties" and enter the macro below. All of the properties are necessary to distinguish the version: all the different versions of Word/WordPad that I tested updated at least one thing, but there was no consistency (I'm as shocked as you are!). Remember, you have to do this before opening the document in your current Word, because it destroys the original information. --Sam<pre>Option Explicit

    Sub DisplayFileType()
    Dim oFilePropReader As DSOleFile.PropertyReader
    Dim oDocProp As DSOleFile.DocumentProperties
    Dim strFile As String
    strFile = "c:Test.doc"
    Set oFilePropReader = New DSOleFile.PropertyReader
    Set oDocProp = oFilePropReader.GetDocumentProperties(strFile)
    With oDocProp
    MsgBox strFile & vbCr & .AppName & vbCr & .ProgID & vbCr & .Version
    End With
    Set oDocProp = Nothing
    Set oFilePropReader = Nothing
    End Sub</pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

Posting Permissions

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