首页 > 解决方案 > ActiveX 证书

问题描述

我找到了一个脚本,可以通过网页在特定工作表上打开 excel。

我遇到了一个问题,因为每次我尝试打开它时都会收到一条错误消息,指出 ActiveX 控件未签名。我需要解决此问题,而不是使用允许未签名的 ActiveX 控件之类的解决方法,因为此功能将在我办公室中的每个人的 Intranet 站点上使用。

代码:

<!DOCTYPE html>

<script type="text/javascript">
    function Open_Excel_File(path,sheet)
      {

        fso = new ActiveXObject("Scripting.FileSystemObject");

        if (!fso.FileExists(path))
          alert("Cannot open file.\nFile '" + path + "' doesn't exist.");

        else
         {
           var myApp = new ActiveXObject("Excel.Application");

           if (myApp != null)
             {
               myApp.visible = true;
               Book = myApp.workbooks.open(path);
               var excel_sheet = Book.Worksheets(sheet).Activate;
               myApp.range(f_range).Select;
             }

           else {
             alert ("Cannot open Excel application");
           }
         }
      }
 </script>

 <button onclick="Open_Excel_File('C:\\Users\\sodonnell\\Desktop\\test1.xlsm', 'sheet2');">Rawr</button>

标签: javascripthtmlactivexactivexobject

解决方案


推荐阅读