To start with, do you realise that there are plenty of other editors
(OpenOffice, StarOffice, WordPerfect) who also create valid Word
documents. Hence, it seems pretty useless to look with which version
of Word the document was made in as nowadays there is probably a 10%
chance that they were not made with Word in the first place.
For the oldfashioned .doc files, I do not know the answer.
I do know that .docx files (which are just zip files) store it inside
'app.xml'. You can probably extract it from the WordOpenXml.
Public Function Version()
Dim str As String
Dim locStart As Integer
Dim locEnd As Integer
str = ActiveDocument.WordOpenXML
locStart = InStr(1, str, "<AppVersion>", vbTextCompare) +
Len("<AppVersion>")
locEnd = InStr(1, str, "</AppVersion>", vbTextCompare)
str = Mid(str, locStart, locEnd - locStart)
MsgBox str
End Function
Note that the above code is not really robust. It relies on the fact
that there will only be one <AppVersion> element in the entire docx
file. If someone would define one as part of a custom xml part, the
above code might fail. Hence you should probably check if it is
located inside the correct parent tags as well.
Yves