How to read Custom Version number of Word file in VBS

 

set objShell = WScript.CreateObject("WScript.Shell") 
Set objFSO = CreateObject("Scripting.FileSystemObject")
appDataPath = objShell.ExpandEnvironmentStrings("%APPDATA%")
 
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
 
Set objNormalTemplate = objWord.Documents.Open(appDataPath & "\Microsoft\Templates\Normal.Dotm")
normalTemplateVersion = GetVersionNumber(objNormalTemplate)
objNormalTemplate.Close
 
Set objSetupWordCitrix = objWord.Documents.Open(appDataPath & "\Word\Support\SetupWord.dotm")
setupWordCitrixVersion = GetVersionNumber(objSetupWordCitrix)
If normalTemplateVersion < setupWordCitrixVersion Then
objWord.Run "Main"
End If
objWord.Quit
End If
 
 
Function CDPExists(objDoc, cdpName)
Dim cdp
CDPExists = False
For Each cdp In objDoc.CustomDocumentProperties
If cdp.Name = cdpName Then
CDPExists = True
Exit Function
End If
Next
End Function
 
Function GetVersionNumber(objDoc)
lngVersionNumber = 0
If CDPExists(objDoc, "Version") Then
lngVersionNumber = CLng(objDoc.CustomDocumentProperties("Version").Value)
End If
GetVersionNumber = lngVersionNumber
End Function

 

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Tags: custom, normal.dot, Normal.dotm, styles, VBS, version, word, Word 2010

Trackback from your site.