Using JavaScript to determine the office version is very useful in project development. Because it is online office editing in OA system, we need to make the office online editing tool support multiple versions of office at the same time, such as office2003 and 2007. When the office is installed, the key value will be written in the registry, and the specific location is HKEY_CURRENT_USER/Software/Microsoft/Office.
We open the registry and you can see the version of office. The corresponding relationship between the office version and the registry key value is as follows:
The code copy is as follows:
11.0 office2003;
12.0 office2007;
14.0 office2010;
The code copy is as follows:
var version="";
function readOfficeVersion()
{
var word=null;
try
{
word=new ActiveXObject("Word.application");
}catch(e)
{
alert("1. Please check whether your machine has been installed with Microsoft Office 2003/2007;/n2. You check whether your browser settings are enabled for ActiveX controls.");
}
if(word.Version==="11.0")
{
version="office2003";
}
else if(word.Version==="12.0")
{
version="office2007";
}
else if(word.Version==="14.0")
{
version="office2010";
} //Closing Word process in time
word.Application.Quit();
return version;
}