Using JavaScript to determine the office version is very useful in project development. Since it is an online office editor in an OA system, we need to make the office online editing tool support multiple versions of office at the same time, such as office 2003 and 2007. When office is installed, the key value will be written in the registry. The specific location is HKEY_CURRENT_USER/Software/Microsoft/Office.
When we open the registry, we can see the version of office. The corresponding relationship between the office version and the registry key value is as follows:
11.0 office2003;
12.0 office2007;
14.0 office2010;
var version="";
function readOfficeVersion( )
{
var word=null;
try
{
word=new ActiveXObject("Word.application");
}catch(e)
{
alert("1. Please check whether your machine has Microsoft Office 2003/2007 installed;/n2. Please check whether your browser settings enable 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";
} //Close the Word process in a timely manner
word.Application.Quit();
return version;
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn