VBA to determine Word version of a document

E

EKH

Hi,

I need to create a vba macro that will provide info about which version
(fileformat) of Word the active document was saved in.

I tried the following, but no luck:

Sub CheckDocType()
'Assuming that constants are as follows: Format 15 - docx; Format 16 - docm
If ActiveDocument.SaveFormat = 15 Or ActiveDocument.SaveFormat = 16 Then
MsgBox "This document is a Word 2007."
End If
End Sub

Thanks
 
G

Graham Mayor

Try

Dim sFname As String
sFname = ActiveDocument.Name
If ActiveDocument.Saved = True Then
If Right(UCase(sFname), 2) = "CX" _
Or Right(UCase(sFname), 2) = "CM" Then
MsgBox "Word 2007"
Else
MsgBox "Not Word 2007"
End If
End If


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
E

EKH

Thanks much!!

Graham Mayor said:
Try

Dim sFname As String
sFname = ActiveDocument.Name
If ActiveDocument.Saved = True Then
If Right(UCase(sFname), 2) = "CX" _
Or Right(UCase(sFname), 2) = "CM" Then
MsgBox "Word 2007"
Else
MsgBox "Not Word 2007"
End If
End If


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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