Determine what word version a document is saved as (not the version of word runnintg)


I want to use VBA to return what version of Word a document is saved as. Can anyone point me in the right direction?

LVL 23
Kelvin SparksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi Kelvin,

You should be able to compare ActiveDocument.SaveFormat against WdSaveFormat - wdFormatDocument, wdFormatDocument97, wdFormatHTML etc

Hope this helps.
So, this code

 If ActiveDocument.Saved Then
        MsgBox ActiveDocument.SaveFormat
End If

prints out the integer representation of the format. You would want to do something like

If ActiveDocument.SaveFormat = wdFormatDocument97 then
   'do a
   ' do b
end if

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You need a dll from here:
(I know it says it's .net but it works in vba as well)

You set a reference to that dll (DSO Ole Document Properties 2.1).

The problem then is finding out how to use it..

This is put together from what I've found on the net..
Sub getfileprops(vfile as string)

Dim FName As String
Dim DSO As DSOFile.OleDocumentProperties
Set DSO = New DSOFile.OleDocumentProperties

'FName = "i:\filename.doc"      ' for testing
fname = vfile    ' from parameter

DSO.Open sfilename:=FName
Debug.Print DSO.SummaryProperties.ApplicationName
Debug.Print DSO.SummaryProperties.Author
End Sub

This returns the version in the ApplicationName property.
Like...Microsoft Word 10.0
You will have to parse the result if you want the numeric version number and note that a Word 2003 document doesn't return a number, only the name (I guess that's how you can tell it's a Word 2003 doc)

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Chris BottomleySoftware Quality Lead EngineerCommented:
I'll be interested to know if that works as I have already tried examining a file off a 2003 pc on a 2007 machine and the saveformat in both cases was the same

Chris BottomleySoftware Quality Lead EngineerCommented:
Sorry Peter I wasn't referring to your post
Chris BottomleySoftware Quality Lead EngineerCommented:
I will await this with interest since on both a 2003 file saved in word 2003 and a 2007 file saved in word 2007, when each are opened and closed on a 2007 machine the version reported in the version parameter is 12.0 and the application as simply Microsoft Word.  

WHen the imported 2003 file is examined without passing through 2007 it reports as version 11 suggesting the parameter is the editor version rather than the file save format BUT ... it's not my question so I am simply posting as a reference, though I am interested in a solution.

No - I don't think my post is very relevant.
For a reason only known to the hidden areas of my brain I read the original Q as applying to a Closed file.

Not sure if you're referring to my post, Chris. If you are, I've got to reply with the classic of "works on my machine". .doc returns 0, the various xml formats 11, 12, 13.
Chris BottomleySoftware Quality Lead EngineerCommented:

Just to be clear ... i'm not the author but I did try a check for my own info with your post, (always good to learn from your peers) and both document versions said 0, can't say why it is different for me, (but it could be the OS/Word versions which in my case are Vista/2007) but at least Kelvin now knows to look into the detail to be sure of a practical solution and if the results match yours then he has a result.

Kelvin SparksAuthor Commented:
Thanks foir the help. Was just what I needed. Not waorried about 2007 as we are doing standardisation to 2003 from earlier versions..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.