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

 

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...