VBA macro to identify word version

J

Jayashree

Hi

How do I identify programmatically on what version of Word (2000 or 2003 or
2007 on a PC and 2001 or 2004 or 2008 on a Mac) has the document that is
received has been created.

Can somebody resolve this issue right away?

Regards
 
T

Tony Jollans

On the PC you can check Application.Version. I don't know about Macs, beyond
the fact that 2008 doesn't have VBA.
 
J

Jayashree

I think you have not understood my question. Application.Version returns the
version of Word you are running on your system and not the version in which
the document was created.
 
J

Jay Freedman

You can try the DSOfile.dll available from
http://support.microsoft.com/kb/224351. I don't know what value, if any, would
be retrieved from documents created in Mac Word.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
 
B

Brian

As you say, the Application.Version returns the version of Word you are
running.

If you have created a document on 2007 and save and distribute as a 97-2003
version, then you would only be able to see the version you are running. I
don't believe that you can identify the version of the application on another
machine.

I am willing to stand corrected......
 
T

Tony Jollans

Sorry!

I don't think there's any foolproof way, and I'm not sure (on the PC, at
least) under what conditions it matters. I believe
ActiveDocument.BuiltInDocumentProperties("Application Name") may differ by
version but you'd have to (a) check out what the varying strings were and
(b) see whether they reflected creation or last update.
 
P

p0

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
 
J

Jayashree

Are the extensions for other editors' format the same as ".DOC or .RTF". If
yes, then I understand but my question was only to identify for the files
created on MS Word. On Word 2007 docx format, I can try if that works but if
they save it on a 97-2003 compatible mode then?
 
P

p0

Yes. OpenOffice for example is often used by people who use linux as
an operating system and want to read and write ".doc" files.
WordPerfect is a Windows editor which is still widely used in a lot of
places. It has its own extension by default, but can save files as
".doc" without problem. And the ".rtf" extension can be used by
WordPad as well to save text with markup.

If they save it in 97-2003 compatible mode, the extension will be
".doc" and the method won't work as their is no WordOpenXML property
which you can access.

Yves
 
J

Jayashree

Yes agreed! Still my question is not answered. I am not worried about the
files that was created on a different editor but I want to find the version
of a document that was created on MS Word application as all our writers use
only MS Word and not any other editors because we have given tools that work
 
T

Tony Jollans

Can you explain why you want to know? The whole point of the suffix - of
them all being .doc files - is that it doesn't matter what created them.
What do you want to do that will work with one version but not another?
Perhaps there may be a different approach you can use.
 
J

Jayashree

Tony, we find that the art images with text (within textboxes) that are
created using Word's drawing toolbar on one version - say Word 2007, is not
fully visible on Word 2000 and the REF fields gets updated incorrectly
(becomes 0 on printing). On googling, I found that it is due to bad fields or
the field must of got corrupted when trying to update on a version other than
the version that was originally created. We receive files from various
authors/writers who work on different versions of Word and since our
manuscript is the Word document, we find these discrepancies very often and
everytime we can't be asking them on which version they created the document
on. So I am trying to figure out through a macro which can identify this.
Hope I have made it clear now. Let me know if this is possible. Thanks...
 
P

p0

Why not unlink the REF fields? That way only static text is left, and
the results won't be updated when printed.

Yves
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top