Tech Tip: Utility Method to Get Version of MS Office Last Opened
PRODUCT: 4D | VERSION: 16 | PLATFORM: Win
Published On: June 15, 2018
Below is a utility method to return the version of the Microsoft Office that was last opened by querying the registry. This feature is only available on Windows.
// Method: Util_Get_Curr_MSOffice // // Details: (WINDOWS ONLY) // Returns the last opened version of Microsoft Office in String Format // //---------------------------------------------------------- C_TEXT($0) C_TEXT($cmd_t) C_TEXT($in_t;$out_t;$err_t) $0:="" $cmd_t:="REG QUERY HKEY_CLASSES_ROOT\\Word.Application\\CurVer" SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"True") LAUNCH EXTERNAL PROCESS($cmd_t;$in_t;$out_t;$err_t) $found_b:=Match regex("ERROR";$out_t;1) If ($found_b=False) $found_b:=Match regex("(\d)+";$out_t;1;$pos_l;$len_l) If ($found_b=True) $ver_t:=Substring($out_t;$pos_l;$len_l) Case of : ($ver_t="7") $0:="Office 97" : ($ver_t="8") $0:="Office 98" : ($ver_t="9") $0:="Office 2000" : ($ver_t="10") $0:="Office XP" : ($ver_t="11") $0:="Office 2003" : ($ver_t="12") $0:="Office 2007" : ($ver_t="14") $0:="Office 2010" : ($ver_t="15") $0:="Office 2013" : ($ver_t="16") $0:="Office 2016" End case End if End if |
Example of using the method:
C_TEXT($MSOfficeVer) $MSOfficeVer:=Util_Get_Curr_MSOffice |